This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A347409 #38 Oct 24 2022 21:59:33 %S A347409 0,1,4,2,4,4,4,3,4,4,4,4,4,4,5,4,4,4,4,4,6,4,5,4,4,4,5,4,4,5,5,5,4,4, %T A347409 5,4,4,4,4,4,5,6,4,4,4,5,5,4,4,4,4,4,5,5,5,4,4,4,4,5,5,5,5,6,4,4,4,4, %U A347409 4,5,5,4,5,4,8,4,4,4,4,4,5,5,5,6,8,4,4 %N A347409 Longest run of halving steps in the trajectory from n to 1 in the Collatz map (or 3x+1 problem), or -1 if no such trajectory exists. %C A347409 If the longest run of halving steps occurs as the final part of the trajectory, a(n) = A135282(n), otherwise a(n) > A135282(n). %C A347409 Every nonnegative integer appears in the sequence at least once, since for any k >= 0 a(2^k) = k. %C A347409 Conjecture: every integer >= 4 appears in the sequence infinitely many times. %H A347409 Charles R Greathouse IV, <a href="/A347409/b347409.txt">Table of n, a(n) for n = 1..10000</a> %H A347409 <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a> %e A347409 a(15) = 5 because the Collatz trajectory starting at 15 contains, as the longest halving run, a 5-step subtrajectory (namely, 160 -> 80 -> 40 -> 20 -> 10 -> 5). %t A347409 nterms=100;Table[c=n;sm=0;While[c>1,If[OddQ[c],c=3c+1,If[(s=IntegerExponent[c,2])>sm,sm=s];c/=2^s]];sm,{n,nterms}] %o A347409 (PARI) a(n)=my(nb=0); while (n != 1, if (n % 2, n=3*n+1, my(x = valuation(n, 2)); n /= 2^x; nb = max(nb, x));); nb; \\ _Michel Marcus_, Sep 03 2021 %o A347409 (Python) %o A347409 def A347409(n): %o A347409 m, r = n, 0 %o A347409 while m > 1: %o A347409 if m % 2: %o A347409 m = 3*m + 1 %o A347409 else: %o A347409 s = bin(m)[2:] %o A347409 c = len(s)-len(s.rstrip('0')) %o A347409 m //= 2**c %o A347409 r = max(r,c) %o A347409 return r # _Chai Wah Wu_, Sep 29 2021 %Y A347409 Cf. A006370, A070165, A135282. %Y A347409 Cf. A347668 (indices of records), A347669 (indices of first occurrences), A348007. %K A347409 nonn,easy %O A347409 1,3 %A A347409 _Paolo Xausa_, Aug 30 2021