could someone please help me finding the bug in this program...? it will really help me...
i keep getting error 216...
var
i,j,temp,max:longint;
x:longint;
b:array [1..100000000000000] of boolean;
nb:array [1..100000000000000] of integer;
function cyc(c:int64):integer;
begin
if b[c] then
cyc:=nb[c]
else
begin
if (c mod 2=1) then
cyc:=cyc((3*c)+1)+1
else
cyc:=cyc(c div 2)+1;
nb[c]:=cyc;
b[c]:=true;
end;
end;
begin
b[1]:=true; nb[1]:=1;
while not eof do
begin
readln(i,j);
temp:=0; max:=0;
if i<=j then
for x:=i to j do
begin
temp:=cyc(x);
if temp>max then
max:=temp;
end
else
for x:=i downto j do
begin
temp:=cyc(x);
if temp>max then
max:=temp;
end;
writeln(i,' ',j,' ',max);
end;
end.
this problem is from UVa, 100 - The 3n + 1
Bookmarks