OFFSET
1,2
COMMENTS
LINKS
Chris K. Caldwell and G. L. Honaker, Jr., Curio for 5
EXAMPLE
The trajectory of 13 under repeated applications of the Collatz map starts 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, requiring 9 steps to reach 1. 9 < 13, so 13 is a term of the sequence.
MATHEMATICA
nsteps[n_] := -1 + Length @ NestWhileList[If[OddQ[#], 3 # + 1, #/2] &, n, # > 1 &]; Select[Range[100], nsteps[#] < # &] (* Amiram Eldar, Jul 14 2021 *)
PROG
(PARI) a006370(n) = if(n%2==0, n/2, 3*n+1)
is(n) = my(x=n, i=0); while(1, if(x==1, if(i < n, return(1), return(0))); x=a006370(x); i++)
CROSSREFS
KEYWORD
nonn
AUTHOR
Felix Fröhlich, Jul 14 2021
STATUS
approved