OFFSET
1,3
COMMENTS
A006577 is the number of halving and tripling steps to reach 1 in '3x+1' problem.
The end of the cycle is 1 or 5 for n = 5, 32, 57, 59, 344, 346, 348, 349, ...
LINKS
Michel Lagneau, Table of n, a(n) for n = 1..10000
EXAMPLE
MAPLE
for n from 1 to 200 do:
m:=n: a:=2:
for it from 1 to 1000
while (a>1) do:
jj:=0: a:=0: x:=m:
if m=5 then
printf(`%d, `, it-1): jj:=1:
else
for i from 1 to 1000
while (x>1) do:
if irem(x, 2)=0 then
x := x/2: a := a+1:
else
x := 3*x+1: a := a+1:
fi:
od:
m:=a:
fi:
od:
if jj=0 then
printf(`%d, `, it-1):
fi:
od:
MATHEMATICA
Collatz[n_] := NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]; f[n_] := Length[Collatz[n]] - 1; Table[k = Rest[NestWhileList[f, n, UnsameQ, All]]; If[k[[1]] == n, 0, k = DeleteCases[k, 0]; If[Length[k] > 1 && k[[-1]] == k[[-2]], k = Most[k]]; Length[k]], {n, 100}] (* T. D. Noe, Mar 01 2013 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Michel Lagneau, Mar 01 2013
STATUS
approved