A258772 Number of fixed points in the Collatz (3x+1) trajectory of n.
1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0
Offset: 1
Keywords
Examples
For n = 5, the trajectory is T(5) = [5, 16, 8, 4, 2, 1]. Since the fourth term in this sequence is 4, this is a fixed point. Since there is only one fixed point, a(5) = 1. For n = 6, the trajectory is T(6) = [6, 3, 10, 5, 16, 8, 4, 2, 1]. Here, the k-th term in this trajectory does not equal k for any possible k. So a(6) = 0.
Links
Programs
-
Mathematica
A258772[n_]:=Count[MapIndexed[{#1}==#2&,NestWhileList[If[OddQ[#],3#+1,#/2]&,n,#>1&]],True];Array[A258772,100] (* Paolo Xausa, Nov 06 2023 *)
-
PARI
Tvect(n)=v=[n];while(n!=1,if(n%2,k=(3*n+1);v=concat(v,k);n=k);if(!(n%2),k=n/2;v=concat(v,k);n=k));v for(n=1,200,d=Tvect(n);c=0;for(i=1,#d,if(d[i]==i,c++));print1(c,", "))
Comments