Wednesday, March 5, 2025

Collatz solution's Draft (Project Euler №14)

program Hello;

var n: Int64;

   maxsteps, steps : smallint;

begin

  writeln ('Hello World');

  //steps := 1;

  n := 0;

  maxsteps := 0;

  for n := 2 to 13 do

  begin

    steps := 1;

    while (n <> 1) do

    begin

      if odd(n) then n:= 3*n+1

      else n:= trunc(n/2);

      inc(steps);

    end;

    if steps > maxsteps then maxsteps := steps;

  end;

  writeln(maxsteps);

end.


No comments:

Post a Comment

Dbf не чіпаємо, маніпуляції тільки з itab

 1. Dbf tab містить ВСІ 67-68 полів,  Ztab - тільки ті 25-45 полів що використовуються в продовженні ресурсів, їх і копіюємо Dbf не редагува...