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 A006577 M4323 #228 Feb 16 2025 08:32:30 %S A006577 0,1,7,2,5,8,16,3,19,6,14,9,9,17,17,4,12,20,20,7,7,15,15,10,23,10,111, %T A006577 18,18,18,106,5,26,13,13,21,21,21,34,8,109,8,29,16,16,16,104,11,24,24, %U A006577 24,11,11,112,112,19,32,19,32,19,19,107,107,6,27,27,27,14,14,14,102,22 %N A006577 Number of halving and tripling steps to reach 1 in '3x+1' problem, or -1 if 1 is never reached. %C A006577 The 3x+1 or Collatz problem is as follows: start with any number n. If n is even, divide it by 2, otherwise multiply it by 3 and add 1. Do we always reach 1? This is a famous unsolved problem. It is conjectured that the answer is yes. %C A006577 It seems that about half of the terms satisfy a(i) = a(i+1). For example, up to 10000000, 4964705 terms satisfy this condition. %C A006577 n is an element of row a(n) in triangle A127824. - _Reinhard Zumkeller_, Oct 03 2012 %C A006577 The number of terms that satisfy a(i) = a(i+1) for i being a power of ten from 10^1 through 10^10 are: 0, 31, 365, 4161, 45022, 477245, 4964705, 51242281, 526051204, 5378743993. - _John Mason_, Mar 02 2018 %C A006577 5 seems to be the only number whose value matches its total number of steps (checked to n <= 10^9). - _Peter Woodward_, Feb 15 2021 %D A006577 R. K. Guy, Unsolved Problems in Number Theory, E16. %D A006577 N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence). %H A006577 N. J. A. Sloane, <a href="/A006577/b006577.txt">Table of n, a(n) for n = 1..10000</a> %H A006577 David Eisenbud and Brady Haran, <a href="https://www.youtube.com/watch?v=5mFpVDpKX70">UNCRACKABLE? The Collatz Conjecture</a>, Numberphile video, 2016. %H A006577 Geometry.net, <a href="http://www.geometry.net/theorems_and_conjectures/collatz_problem.html">Links on Collatz Problem</a> %H A006577 Christian Hercher, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL26/Hercher/hercher5.html">There are no Collatz m-Cycles with m <= 91</a>, J. Int. Seq. (2023) Vol. 26, Article 23.3.5. %H A006577 Jason Holt, <a href="/A006577/a006577_1Blog.png">Log-log plot of first billion terms</a> %H A006577 Jason Holt, <a href="/A006577/a006577_1B.png">Plot of 1 billion values of the number of steps to drop below n</a> (A060445), log scale on x axis %H A006577 Jason Holt, <a href="/A006577/a006577_10B.png">Plot of 10 billion values of the number of steps to drop below n</a> (A060445), log scale on x axis %H A006577 A. Krowne, <a href="https://planetmath.org/collatzproblem">Collatz problem</a>, PlanetMath.org. %H A006577 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 A006577 J. C. Lagarias, <a href="http://www.cfrd.cl/~moises/DVD/05Bibliografia%20-%20Geometria%20Sagrada/Matematica%20Recreativa/Martin%20Gardner/Martin%20Gardner%20-%20The%20Mathemagician%20and%20Pied%20Puzzler%20-%20A%20Collection%20in%20Tribute%20to%20Martin%20Gardner.pdf">How random are 3x+1 function iterates?</a>, in The Mathemagician and the Pied Puzzler - A Collection in Tribute to Martin Gardner, Ed. E. R. Berlekamp and T. Rogers, A. K. Peters, 1999, pp. 253-266. %H A006577 J. C. Lagarias, <a href="http://arxiv.org/abs/math/0608208">The 3x+1 Problem: an annotated bibliography, II (2000-2009)</a>, arXiv:0608208 [math.NT], 2006-2012. %H A006577 J. C. Lagarias, ed., <a href="http://www.ams.org/bookstore-getitem/item=mbk-78">The Ultimate Challenge: The 3x+1 Problem</a>, Amer. Math. Soc., 2010. %H A006577 Jeffrey C. Lagarias, <a href="https://arxiv.org/abs/2111.02635">The 3x+1 Problem: An Overview</a>, arXiv:2111.02635 [math.NT], 2021. %H A006577 M. Le Brun, <a href="/A006577/a006577.pdf">Email to N. J. A. Sloane, Jul 1991</a> %H A006577 Mathematical BBS, <a href="http://felix.unife.it/Root/d-Mathematics/d-Number-theory/b-3x+1">Biblography on Collatz Sequence</a> %H A006577 P. Picart, <a href="http://trucsmaths.free.fr/js_syracuse.htm">Algorithme de Collatz et conjecture de Syracuse</a> %H A006577 E. Roosendaal, <a href="http://www.ericr.nl/wondrous/index.html">On the 3x+1 problem</a> %H A006577 J. L. Simons, <a href="http://dx.doi.org/10.1090/S0025-5718-04-01728-4">On the nonexistence of 2-cycles for the 3x+1 problem</a>, Math. Comp. 75 (2005), 1565-1572. %H A006577 N. J. A. Sloane, <a href="https://arxiv.org/abs/2301.03149">"A Handbook of Integer Sequences" Fifty Years Later</a>, arXiv:2301.03149 [math.NT], 2023, p. 8. %H A006577 G. Villemin's Almanach of Numbers, <a href="http://translate.google.com/translate?hl=en&sl=fr&u=http://villemin.gerard.free.fr/Wwwgvmm/Iteration/Syracuse.htm#top">Cycle of Syracuse</a> %H A006577 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/CollatzProblem.html">Collatz Problem</a> %H A006577 Wikipedia, <a href="https://en.wikipedia.org/wiki/Collatz_conjecture">Collatz Conjecture</a> %H A006577 <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a> %F A006577 a(n) = A006666(n) + A006667(n). %F A006577 a(n) = A112695(n) + 2 for n > 2. - _Reinhard Zumkeller_, Apr 18 2008 %F A006577 a(n) = A008908(n) - 1. - _L. Edson Jeffery_, Jul 21 2014 %F A006577 a(n) = A135282(n) + A208981(n) (after _Alonso del Arte_'s comment in A208981), if 1 is reached, otherwise a(n) = -1. - _Omar E. Pol_, Apr 10 2022 %F A006577 a(n) = 2*A007814(n + 1) + a(A085062(n)) + 1 for n > 1. - _Wing-Yin Tang_, Jan 06 2025 %e A006577 a(5)=5 because the trajectory of 5 is (5,16,8,4,2,1). %p A006577 A006577 := proc(n) %p A006577 local a,traj ; %p A006577 a := 0 ; %p A006577 traj := n ; %p A006577 while traj > 1 do %p A006577 if type(traj,'even') then %p A006577 traj := traj/2 ; %p A006577 else %p A006577 traj := 3*traj+1 ; %p A006577 end if; %p A006577 a := a+1 ; %p A006577 end do: %p A006577 return a; %p A006577 end proc: # _R. J. Mathar_, Jul 08 2012 %t A006577 f[n_] := Module[{a=n,k=0}, While[a!=1, k++; If[EvenQ[a], a=a/2, a=a*3+1]]; k]; Table[f[n],{n,4!}] (* _Vladimir Joseph Stephan Orlovsky_, Jan 08 2011 *) %t A006577 Table[Length[NestWhileList[If[EvenQ[#],#/2,3#+1]&,n,#!=1&]]-1,{n,80}] (* _Harvey P. Dale_, May 21 2012 *) %o A006577 (PARI) a(n)=if(n<0,0,s=n; c=0; while(s>1,s=if(s%2,3*s+1,s/2); c++); c) %o A006577 (PARI) step(n)=if(n%2,3*n+1,n/2); %o A006577 A006577(n)=if(n==1,0,A006577(step(n))+1); \\ _Michael B. Porter_, Jun 05 2010 %o A006577 (Haskell) %o A006577 import Data.List (findIndex) %o A006577 import Data.Maybe (fromJust) %o A006577 a006577 n = fromJust $ findIndex (n `elem`) a127824_tabf %o A006577 -- _Reinhard Zumkeller_, Oct 04 2012, Aug 30 2012 %o A006577 (Python) %o A006577 def a(n): %o A006577 if n==1: return 0 %o A006577 x=0 %o A006577 while True: %o A006577 if n%2==0: n//=2 %o A006577 else: n = 3*n + 1 %o A006577 x+=1 %o A006577 if n<2: break %o A006577 return x %o A006577 print([a(n) for n in range(1, 101)]) # _Indranil Ghosh_, Jun 05 2017 %o A006577 (Python) %o A006577 def A006577(n): %o A006577 ct = 0 %o A006577 while n != 1: n = A006370(n); ct += 1 %o A006577 return ct # _Ya-Ping Lu_, Feb 22 2024 %o A006577 (R) collatz<-function(n) ifelse(n==1,0,1+ifelse(n%%2==0,collatz(n/2),collatz(3*n+1))); sapply(1:72, collatz) # _Christian N. K. Anderson_, Oct 09 2024 %Y A006577 See A070165 for triangle giving trajectories of n = 1, 2, 3, .... %Y A006577 Cf. A006370, A125731, A127885, A127886, A008908, A112695, A135282, A208981, A025586. %Y A006577 See also A008884, A161021, A161022, A161023. %K A006577 nonn,nice,easy,hear,look %O A006577 1,3 %A A006577 _N. J. A. Sloane_, _Bill Gosper_ %E A006577 More terms from Larry Reeves (larryr(AT)acm.org), Apr 27 2001 %E A006577 "Escape clause" added to definition by _N. J. A. Sloane_, Jun 06 2017