login
Nonnegative integers in the order in which they appear first in A006577.
2

%I #28 Oct 06 2021 07:56:16

%S 0,1,7,2,5,8,16,3,19,6,14,9,17,4,12,20,15,10,23,111,18,106,26,13,21,

%T 34,109,29,104,11,24,112,32,107,27,102,22,115,35,110,30,92,105,118,25,

%U 87,38,100,113,69,33,95,46,108,121,28,41,90,103,116,36,85,54

%N Nonnegative integers in the order in which they appear first in A006577.

%C This is A006577 with duplicates removed.

%C This is a permutation of the nonnegative integers.

%H Alois P. Heinz, <a href="/A337150/b337150.txt">Table of n, a(n) for n = 1..1000</a>

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

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the nonnegative integers</a>

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

%F a(n) = A006577(A337149(n)).

%F a(n) = A006577(n) for 1 <= n <= 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 g:= proc(n) option remember; local t;

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

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

%p end:

%p h:= proc(n) option remember; local k; for k

%p from 1+h(n-1) while g(k)>1 do od; k

%p end: h(0):=0:

%p a:= n-> collatz(h(n)):

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

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

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

%t b[_] = 0;

%t g[n_] := g[n] = Module[{t}, If[n==1, 0, g[n-1]];

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

%t h[n_] := h[n] = Module[{k}, For[k = 1+h[n-1],

%t g[k]>1, k++]; k]; h[0] = 0;

%t a[n_] := a[n] = collatz[h[n]];

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

%Y Cf. A006577, A337149.

%K nonn,look

%O 1,3

%A _Alois P. Heinz_, Jan 27 2021