A000034 Period 2: repeat [1, 2]; a(n) = 1 + (n mod 2).
1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2
Offset: 0
References
- Jozsef Beck, Combinatorial Games, Cambridge University Press, 2008.
- J.-M. De Koninck and A. Mercier, 1001 Problèmes en Théorie Classique des Nombres, Problème 545 pages 73 and 260, Ellipses, Paris 2004.
- N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
Links
- Sean A. Irvine, Table of n, a(n) for n = 0..9999
- Paul Barry, On a Central Transform of Integer Sequences, arXiv:2004.04577 [math.CO], 2020.
- Glen Joyce C. Dulatre, Jamilah V. Alarcon, Vhenedict M. Florida and Daisy Ann A. Disu, On Fractal Sequences, DMMMSU-CAS Science Monitor (2016-2017) Vol. 15 No. 2, 109-113.
- Daniele A. Gewurz and Francesca Merola, Sequences realized as Parker vectors of oligomorphic permutation groups, J. Integer Seqs., Vol. 6, 2003.
- David Guichard, Sperner's Theorem
- INRIA Algorithms Project, Encyclopedia of Combinatorial Structures 383
- Agustín Moreno Cañadas, Hernán Giraldo and Robinson Julian Serna Vanegas, Some integer partitions induced by orbits of Dynkin type, Far East Journal of Mathematical Sciences (FJMS), Vol. 101, No. 12 (2017), pp. 2745-2766.
- Wikipedia, Collatz conjecture
- Index entries for linear recurrences with constant coefficients, signature (0,1).
Crossrefs
Programs
-
GAP
List([0..120],n->1+(n mod 2)); # Muniru A Asiru, Feb 01 2019
-
Haskell
a000034 = (+ 1) . (`mod` 2) a000034_list = cycle [1,2] -- Reinhard Zumkeller, Jul 03 2012, Dec 02 2011 and corrected by James Spahlinger, Oct 08 2012
-
Magma
[1+(n mod 2) : n in [0..100]]; // Wesley Ivan Hurt, Sep 11 2014
-
Maple
(1+2*x)/(1-x^2); A000034 := proc(n) op((n mod 2)+1,[1,2]) ; end proc: # R. J. Mathar, Feb 05 2011
-
Mathematica
a[n_] := If[OddQ[n], 2, 1]; Table[a[n], {n, 0, 90}] (* Stefan Steinerberger, Apr 17 2006 *) Nest[ Flatten[# /. { 0 -> {1}, 1 -> {2}, 2 -> {1, 2, 1} }] &, {1}, 8] (* Robert G. Wilson v, May 20 2014 *)
-
PARI
a(n)=1+n%2
-
PARI
a(n)=1+bittest(n,0) \\ M. F. Hasler, Jan 13 2012
-
Python
def A000034(n): return 1 + (n & 1) # Chai Wah Wu, May 25 2022
Formula
G.f.: (1+2*x)/(1-x^2).
a(n) = 2^((1-(-1)^n)/2) = 2^(ceiling(n/2) - floor(n/2)). - Paul Barry, Jun 03 2003
a(n) = (3-(-1)^n)/2; a(n) = 1 + (n mod 2) = 3-a(n-1) = a(n-2) = a(-n).
a(n) = gcd(n-1, n+1). - Paul Barry, Sep 16 2004
Binomial transform of A123344, inverse binomial transform of A003945. - Philippe Deléham, Jun 04 2007
a(n) = A134451(n+1). - Reinhard Zumkeller, Oct 27 2007
a(n) = if(n=0,1,if(mod(a(n-1),2)=0,a(n-1)/2,(3*a(n-1)+1)/2)). See Collatz conjecture. - Paul Barry, Mar 31 2008
a(n) = 2^n (mod 3). - Vincenzo Librandi, Feb 05 2011
a(n) = A000035(n) + 1. - M. F. Hasler, Jan 13 2012
a(n) = abs(sin(n*Pi/2) - 2*cos(n*Pi/2)). - Mohammad K. Azarian, Mar 12 2012
a(n) = A010704(n) / 3. - Reinhard Zumkeller, Jul 03 2012
a(n) = floor((4/33)*10^(n+1)) mod 10. - Hieronymus Fischer, Jan 03 2013
a(n) = floor((5/8)*3^(n+1)) mod 3. - Hieronymus Fischer, Jan 03 2013
a(n) = floor((n+1)*3/2) - floor((n)*3/2). - Hailey R. Olafson, Jul 23 2014
a(n) = denominator(n/2). - Wesley Ivan Hurt, Sep 11 2014
Dirichlet g.f.: zeta(s)*(1 + 1/2^s). - Mats Granvik, Jul 18 2016
E.g.f.: 2*sinh(x) + cosh(x). - Ilya Gutkovskiy, Jul 18 2016
a(n) = A010693(n) - 1. - Filip Zaludek, Oct 29 2016
a(n) = n + 1 - 2*floor(n/2). - Lorenzo Sauras Altuzarra, Jun 28 2019
Limit_{n->oo} (1/n)*Sum_{k=1..n} a(k) = 3/2 (De Koninck reference). - Bernard Schott, Nov 09 2021
Extensions
Better definition from M. F. Hasler, Jan 13 2012
Comments