local limit = tonumber((...)) or 10
local maxsteps = 0
local x = 0
for n=2, limit do
local steps = 0
local m = n
while true do
steps = steps + 1
if m % 2 == 1 then
m = 3*m + 1
else
m = m / 2
if m == 1 then
if steps > maxsteps then
maxsteps = steps
x = n
end
break
end
end
end
end
print(x, maxsteps)
Last edited by Shmuel on Sun 12 Dec, 2021 23:59, edited 1 time in total.