login
n is the a(n)-th positive integer which takes its number of steps to reach 1 in the '3x+1' problem.
2

%I #21 Jan 29 2021 08:37:37

%S 1,1,1,1,1,1,1,1,1,1,1,1,2,1,2,1,1,1,2,2,3,1,2,1,1,2,1,1,2,3,1,2,1,1,

%T 2,1,2,3,1,2,1,3,1,2,3,4,1,1,1,2,3,2,3,1,2,2,1,3,2,4,5,1,2,2,1,2,3,2,

%U 3,4,1,1,1,2,5,3,4,1,2,3,5,1,2,4,5,1,2

%N n is the a(n)-th positive integer which takes its number of steps to reach 1 in the '3x+1' problem.

%H Alois P. Heinz, <a href="/A337144/b337144.txt">Table of n, a(n) for n = 1..65536</a>

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Collatz_conjecture">Collatz Conjecture</a>

%H <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>

%F Ordinal transform of A006577.

%F a(n) = |{ j in {1..n} : A006577(j) = A006577(n) }|.

%e a(13) = 2 because A006577(13) = A006577(12) = 9 != A006577(j) for j < 12.

%p collatz:= proc(n) option remember; `if`(n=1, 0,

%p 1 + collatz(`if`(n::even, n/2, 3*n+1)))

%p end:

%p b:= proc() 0 end:

%p a:= proc(n) option remember; local t;

%p `if`(n=1, 0, a(n-1));

%p t:= collatz(n); b(t):= b(t)+1

%p end:

%p seq(a(n), n=1..120);

%t collatz[n_] := collatz[n] = If[n == 1, 0,

%t 1 + collatz[If[EvenQ[n], n/2, 3n+1]]];

%t b[_] = 0;

%t a[n_] := a[n] = Module[{t},

%t If[n == 1, 0, a[n-1]];

%t t = collatz[n]; b[t] = b[t]+1];

%t Array[a, 120] (* _Jean-François Alcover_, Jan 29 2021, after _Alois P. Heinz_ *)

%Y Cf. A005186, A006577.

%K nonn,look

%O 1,13

%A _Alois P. Heinz_, Jan 27 2021