login
A275663
Number of squares in {n, f(n), f(f(n)), ...., 1}, where f is the Collatz function.
1
1, 1, 3, 2, 3, 3, 3, 2, 4, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 4, 3, 3, 3, 4, 3, 5, 3, 3, 3, 5, 3, 5, 3, 3, 5, 3, 3, 3, 3, 5, 4, 5, 3, 3, 3, 5, 3, 4, 4, 3, 3, 3, 5, 5, 3, 5, 3, 3, 3, 3, 5, 3, 4, 5, 5, 3, 3, 3, 3, 5, 5, 5, 3, 5, 3, 3, 3, 3, 3, 4, 5, 5, 4, 5, 5, 3
OFFSET
1,3
COMMENTS
Or number of squares in the trajectory of n under the 3x+1 map (i.e. the number of squares until the trajectory reaches 1).
EXAMPLE
The finite sequence n, f(n), f(f(n)), ...., 1 for n = 12 is: 12, 6, 3, 10, 5, 16, 8, 4, 2, 1, which has three square terms. Hence a(12) = 3.
MAPLE
a:= proc(n) option remember; `if`(n=1, 1,
`if`(issqr(n), 1, 0)+a(`if`(n::even, n/2, 3*n+1)))
end:
seq(a(n), n=1..100); # Alois P. Heinz, Nov 04 2024
MATHEMATICA
Reap[For[n=1, n <= 100, n++, s=n; t=1; While[s != 1, If[IntegerQ[Sqrt[s]], t++]; If[EvenQ[s], s=s/2, s=3*s+1]]; If[s == 1, Sow[t]]]][[2, 1]] (* Jean-François Alcover, Nov 17 2016, adapted from PARI *)
PROG
(PARI) print1(1, ", "); for(n=2, 100, s=n; t=1; while(s!=1, if(issquare(s), t++, t=t); if(s%2==0, s=s/2, s=(3*s+1)); if(s==1, print1(t, ", "); ); ))
CROSSREFS
Cf. A006577.
Sequence in context: A230258 A016459 A242309 * A369100 A060585 A114451
KEYWORD
nonn
AUTHOR
Michel Lagneau, Aug 04 2016
STATUS
approved