A006370 The Collatz or 3x+1 map: a(n) = n/2 if n is even, 3n + 1 if n is odd.
0, 4, 1, 10, 2, 16, 3, 22, 4, 28, 5, 34, 6, 40, 7, 46, 8, 52, 9, 58, 10, 64, 11, 70, 12, 76, 13, 82, 14, 88, 15, 94, 16, 100, 17, 106, 18, 112, 19, 118, 20, 124, 21, 130, 22, 136, 23, 142, 24, 148, 25, 154, 26, 160, 27, 166, 28, 172, 29, 178, 30, 184, 31, 190, 32, 196, 33
Offset: 0
Examples
G.f. = 4*x + x^2 + 10*x^3 + 2*x^4 + 16*x^5 + 3*x^6 + 22*x^7 + 4*x^8 + 28*x^9 + ... From _Omar E. Pol_, Jan 03 2022: (Start) Written as a rectangular array with six columns read by rows the sequence begins: 0, 4, 1, 10, 2, 16; 3, 22, 4, 28, 5, 34; 6, 40, 7, 46, 8, 52; 9, 58, 10, 64, 11, 70; 12, 76, 13, 82, 14, 88; 15, 94, 16, 100, 17, 106; 18, 112, 19, 118, 20, 124; 21, 130, 22, 136, 23, 142; 24, 148, 25, 154, 26, 160; 27, 166, 28, 172, 29, 178; 30, 184, 31, 190, 32, 196; ... (End)
References
- R. K. Guy, Unsolved Problems in Number Theory, E16.
- J. C. Lagarias, ed., The Ultimate Challenge: The 3x+1 Problem, Amer. Math. Soc., 2010.
- N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
Links
- T. D. Noe, Table of n, a(n) for n = 0..1000
- Darrell Cox, The 3n + 1 Problem: A Probabilistic Approach, Journal of Integer Sequences, Vol. 15 (2012), #12.5.2.
- David Eisenbud and Brady Haran, UNCRACKABLE? The Collatz Conjecture, Numberphile Video, 2016.
- I. Krasikov and J. C. Lagarias, Bounds for the 3x+1 Problem using Difference Inequalities, arXiv:math/0205002 [math.NT], 2002.
- J. C. Lagarias, The 3x+1 problem and its generalizations, Amer. Math. Monthly, 92 (1985), 3-23.
- J. C. Lagarias, The set of rational cycles for the 3x+1 problem, Acta Arithmetica, LVI (1990), pp. 33-53.
- J. C. Lagarias, The 3x+1 Problem: An Annotated Bibliography (1963-2000), arXiv:math/0309224 [math.NT], 2003-2011.
- J. C. Lagarias, The 3x+1 Problem: an annotated bibliography, II (2000-2009), arXiv:math/0608208 [math.NT], 2006-2012.
- Jeffrey C. Lagarias, The 3x+1 Problem: An Overview, arXiv:2111.02635 [math.NT], 2021.
- Simon Plouffe, Approximations de séries génératrices et quelques conjectures, Dissertation, Université du Québec à Montréal, 1992; arXiv:0911.4975 [math.NT], 2009.
- Simon Plouffe, 1031 Generating Functions, Appendix to Thesis, Montreal, 1992.
- E. Roosendaal, On the 3x+1 problem.
- S. Schreiber & N. J. A. Sloane, Correspondence, 1980.
- Eric Weisstein's World of Mathematics, Collatz Problem.
- Wikipedia, Collatz conjecture.
- Index entries for sequences related to 3x+1 (or Collatz) problem
- Index entries for linear recurrences with constant coefficients, signature (0,2,0,-1).
Crossrefs
Programs
-
Haskell
a006370 n | m /= 0 = 3 * n + 1 | otherwise = n' where (n',m) = divMod n 2 -- Reinhard Zumkeller, Oct 07 2011
-
Magma
[(1/4)*(7*n+2-(-1)^n*(5*n+2)): n in [1..70]]; // Vincenzo Librandi, Dec 20 2016
-
Maple
f := n-> if n mod 2 = 0 then n/2 else 3*n+1; fi; A006370:=(4+z+2*z**2)/(z-1)**2/(1+z)**2; # Simon Plouffe in his 1992 dissertation; uses offset 0
-
Mathematica
f[n_]:=If[EvenQ[n],n/2,3n+1];Table[f[n],{n,50}] (* Geoffrey Critzer, Jun 29 2013 *) LinearRecurrence[{0,2,0,-1},{4,1,10,2},70] (* Harvey P. Dale, Jul 19 2016 *)
-
PARI
for(n=1,100,print1((1/4)*(7*n+2-(-1)^n*(5*n+2)),","))
-
PARI
A006370(n)=if(n%2,3*n+1,n/2) \\ Michael B. Porter, May 29 2010
-
Python
def A006370(n): q, r = divmod(n, 2) return 3*n+1 if r else q # Chai Wah Wu, Jan 04 2015
Formula
G.f.: (4*x+x^2+2*x^3) / (1-x^2)^2.
a(n) = (1/4)*(7*n+2-(-1)^n*(5*n+2)). - Benoit Cloitre, May 12 2002
a(n) = ((n mod 2)*2 + 1)*n/(2 - (n mod 2)) + (n mod 2). - Reinhard Zumkeller, Sep 12 2002
a(n) = a(a(2*n)) = -A001281(-n) for all n in Z. - Michael Somos, Nov 10 2016
E.g.f.: (2 + x)*sinh(x)/2 + 3*x*cosh(x). - Ilya Gutkovskiy, Dec 20 2016
From Federico Provvedi, Aug 17 2021: (Start)
Dirichlet g.f.: (1-2^(-s))*zeta(s) + (3-5*2^(-s))*zeta(s-1).
a(n) = ( a(n+2k) + a(n-2k) ) / 2, for every integer k. (End)
a(n) + a(n+1) = A047374(n+1). - Leo Ortega, Aug 22 2025
Extensions
More terms from Larry Reeves (larryr(AT)acm.org), Apr 27 2001
Zero prepended and new Name from N. J. A. Sloane at the suggestion of M. F. Hasler, Nov 06 2017
Comments