%I #61 May 13 2023 13:45:50
%S 4,7,17,12,113,17,79,22,51,33,64,35,128,56,110,53,84,128,107,115,175,
%T 82,477,172,141,182,188,110,159,167,301,206,151,146,128,195,190,299,
%U 208,276,180,185,500,203,229,190,265,270,288,252,299,208,350,348,459,330,314,268,490,361,578
%N Length of the Collatz (3x + 1) trajectory from k = 10^n - 1 to a term less than k, or -1 if the trajectory never goes below k.
%C k = 10^n - 1 = A002283(n) is the repdigit consisting of n digits, all 9s.
%C The sequence seems to be chaotic but broadly increasing.
%C By contrast, repdigits of 1, 3, 5, or 7, have constant dropping times after a few initial values each.
%H <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>
%F a(n) = A074473(10^n-1).
%e a(1) = 4 as for k = 9, the Collatz trajectory begins 9, 28, 14, 7, ...;
%e a(2) = 7 as for k = 99, the Collatz trajectory begins 99, 298, 149, 448, 224, 112, 56, ...;
%e a(3) = 17 as for k = 999, the Collatz trajectory begins 999, 2998, 1499, 4498, 2249, 6748, 3374, 1687, 5062, 2531, 7594, 3797, 11392, 5696, 2848, 1424, 712, ... .
%t collatzLen[a_Integer] := Module[{len = 1, x = a},
%t While[x >= a, If[Mod[x, 2] > 0,
%t x = 3 x + 1,
%t x = Quotient[x, 2]
%t ];
%t len++
%t ];
%t Return[len]
%t ]
%o (Python)
%o def collatz_len(a):
%o length = 1
%o x = a
%o while x >= a:
%o if x % 2 > 0:
%o x = 3 * x + 1
%o else:
%o x = x // 2
%o length += 1
%o return length
%o (PARI) f(n) = if (n%2, 3*n+1, n/2); \\ A006370
%o b(n) = if (n<3, return(n)); my(m=n, nb=0); while (1, m = f(m); nb++; if (m < n, return(nb+1));); \\ A074473
%o a(n) = b(10^n-1); \\ _Michel Marcus_, Mar 28 2023
%Y Cf. A074473, A002283, A006370, A074474, A075483, A075480.
%K nonn
%O 1,1
%A _Paul M. Bradley_, Mar 22 2023
|