OFFSET
1,13
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..65536
Wikipedia, Collatz Conjecture
MAPLE
collatz:= proc(n) option remember; `if`(n=1, 0,
1 + collatz(`if`(n::even, n/2, 3*n+1)))
end:
b:= proc() 0 end:
a:= proc(n) option remember; local t;
`if`(n=1, 0, a(n-1));
t:= collatz(n); b(t):= b(t)+1
end:
seq(a(n), n=1..120);
MATHEMATICA
collatz[n_] := collatz[n] = If[n == 1, 0,
1 + collatz[If[EvenQ[n], n/2, 3n+1]]];
b[_] = 0;
a[n_] := a[n] = Module[{t},
If[n == 1, 0, a[n-1]];
t = collatz[n]; b[t] = b[t]+1];
Array[a, 120] (* Jean-François Alcover, Jan 29 2021, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Alois P. Heinz, Jan 27 2021
STATUS
approved