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 A006667 M0019 #108 Apr 10 2025 00:11:56 %S A006667 0,0,2,0,1,2,5,0,6,1,4,2,2,5,5,0,3,6,6,1,1,4,4,2,7,2,41,5,5,5,39,0,8, %T A006667 3,3,6,6,6,11,1,40,1,9,4,4,4,38,2,7,7,7,2,2,41,41,5,10,5,10,5,5,39,39, %U A006667 0,8,8,8,3,3,3,37,6,42,6,3,6,6,11,11,1,6,40,40,1,1,9,9,4,9,4,33,4,4,38 %N A006667 Number of tripling steps to reach 1 from n in '3x+1' problem, or -1 if 1 is never reached. %C A006667 A075680, which gives the values for odd n, isolates the essential behavior of this sequence. - _T. D. Noe_, Jun 01 2006 %C A006667 A033959 and A033958 give record values and where they occur. - _Reinhard Zumkeller_, Jan 08 2014 %D A006667 J.-P. Allouche and J. Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, p. 204, Problem 22. %D A006667 R. K. Guy, Unsolved Problems in Number Theory, E16. %D A006667 N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence). %H A006667 T. D. Noe, <a href="/A006667/b006667.txt">Table of n, a(n) for n = 1..10000</a> %H A006667 J. C. Lagarias, <a href="http://www.cecm.sfu.ca/organics/papers/lagarias/paper/html/paper.html">The 3x+1 problem and its generalizations</a>, Amer. Math. Monthly, 92 (1985), 3-23. %H A006667 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/CollatzProblem.html">Collatz Problem.</a> %H A006667 Wikipedia, <a href="http://en.wikipedia.org/wiki/Collatz_conjecture">Collatz conjecture</a> %H A006667 <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a> %F A006667 a(1) = 0, a(n) = a(n/2) if n is even, a(n) = a(3n+1)+1 if n>1 is odd. The Collatz conjecture is that this defines a(n) for all n >= 1. %F A006667 a(n) = A078719(n) - 1; a(A000079(n))=0; a(A062052(n))=1; a(A062053(n))=2; a(A062054(n))=3; a(A062055(n))=4; a(A062056(n))=5; a(A062057(n))=6; a(A062058(n))=7; a(A062059(n))=8; a(A062060(n))=9. - _Reinhard Zumkeller_, Oct 08 2011 %F A006667 a(n*2^k) = a(n), for all k >= 0. - _L. Edson Jeffery_, Aug 11 2014 %F A006667 a(n) = floor(log(2^A006666(n)/n)/log(3)). - _Joe Slater_, Aug 30 2017 %F A006667 a(n) = a(A085062(n)) + A007814(n+1) for n >= 2. - _Alan Michael Gómez Calderón_, Feb 07 2025 %F A006667 From _Alan Michael Gómez Calderón_, Mar 31 2025: (Start) %F A006667 a(n) = a(A139391(n)) + (n mod 2) for n >= 2; %F A006667 a(n) = a(A139391(A000265(n))) - A209229(n) + 1 for n >= 2; %F A006667 a(n) = a(A000265(A139391(n))) + (n mod 2) for n >= 2. (End) %p A006667 a:= proc(n) option remember; `if`(n<2, 0, %p A006667 `if`(n::even, a(n/2), 1+a(3*n+1))) %p A006667 end: %p A006667 seq(a(n), n=1..100); # _Alois P. Heinz_, Aug 08 2023 %t A006667 Table[Count[Differences[NestWhileList[If[EvenQ[#],#/2,3#+1]&,n,#>1&]], _?Positive], {n,100}] (* _Harvey P. Dale_, Nov 14 2011 *) %o A006667 (PARI) for(n=2,100,s=n; t=0; while(s!=1,if(s%2==0,s=s/2,s=(3*s+1)/2; t++); if(s==1,print1(t,","); ); )) %o A006667 (Haskell) %o A006667 a006667 = length . filter odd . takeWhile (> 2) . (iterate a006370) %o A006667 a006667_list = map a006667 [1..] %o A006667 -- _Reinhard Zumkeller_, Oct 08 2011 %o A006667 (Python) %o A006667 def a(n): %o A006667 if n==1: return 0 %o A006667 x=0 %o A006667 while True: %o A006667 if n%2==0: n/=2 %o A006667 else: %o A006667 n = 3*n + 1 %o A006667 x+=1 %o A006667 if n<2: break %o A006667 return x %o A006667 print([a(n) for n in range(1, 101)]) # _Indranil Ghosh_, Apr 14 2017 %Y A006667 Equals A078719(n)-1. %Y A006667 Cf. A000079, A000265, A006370, A006577, A006666 (halving steps), A092893, A127789, A139391, A209229. %K A006667 nonn,nice,hear %O A006667 1,3 %A A006667 _N. J. A. Sloane_ and _Bill Gosper_ %E A006667 More terms from Larry Reeves (larryr(AT)acm.org), Apr 27 2001 %E A006667 "Escape clause" added to definition by _N. J. A. Sloane_, Jun 06 2017