OFFSET
0,2
LINKS
EXAMPLE
n=4: between iv={1,2,...,16} {2,8}U{3,5,6,10,12,16} provides peak values smaller than or equal with 16, so a(4) = 10 = A087256(4)+4
MAPLE
b:= proc(n) option remember; `if`(n=1, 1,
max(n, b(`if`(n::even, n/2, 3*n+1))))
end:
a:= proc(n) option remember; local t; t:=2^n;
add(`if`(b(i)<=t, 1, 0), i=1..t)
end:
seq(a(n), n=0..20); # Alois P. Heinz, Sep 26 2024
MATHEMATICA
c[x_]:=c[x]=(1-Mod[x, 2])*(x/2)+Mod[x, 2]*(3*x+1); c[1]=1; fpl[x_]:=FixedPointList[c, x]; {$RecursionLimit=1000; m=0}; Table[Print[{xm-1, m}]; m=0; Do[If[ !Greater[Max[fpl[n]], 2^xm], m=m+1], {n, 1, 2^xm}], {xm, 1, 30}]
Collatz[n_] := NestWhileList[If[EvenQ[#], #/2, 3 # + 1] &, n, # > 1 &]; Table[Length[Select[Range[x=2^n], Max[Collatz[#]] <= x &]], {n, 0, 10}] (* T. D. Noe, Apr 29 2013 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Labos Elemer, Jun 14 2004
EXTENSIONS
a(21)-a(32) from Donovan Johnson, Feb 02 2011
a(0) from T. D. Noe, Apr 29 2013
a(33)-a(34) from Donovan Johnson, Jun 05 2013
STATUS
approved