A010873 a(n) = n mod 4.
0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0
Offset: 0
Links
- Antti Karttunen, Table of n, a(n) for n = 0..65536
- Index entries for linear recurrences with constant coefficients, signature (0,0,0,1).
Crossrefs
Programs
-
Haskell
a010873 n = (`mod` 4) a010873_list = cycle [0..3] -- Reinhard Zumkeller, Jun 05 2012
-
Maple
seq(chrem( [n,n], [1,4] ), n=0..80); # Zerinvary Lajos, Mar 25 2009
-
Mathematica
nn=40; CoefficientList[Series[(x+2x^2+3x^3)/(1-x^4), {x,0,nn}], x] (* Geoffrey Critzer, Jul 26 2013 *) Table[Mod[n,4], {n, 0, 100}] (* T. D. Noe, Jul 26 2013 *) PadRight[{},120,{0,1,2,3}] (* Harvey P. Dale, Mar 29 2018 *)
-
PARI
a(n)=n%4 \\ Charles R Greathouse IV, Dec 05 2011
-
Scheme
(define (A010873 n) (modulo n 4)) ;; Antti Karttunen, Nov 07 2017
Formula
a(n) = (1/2)*(3-(-1)^n-2*(-1)^floor(n/2));
also a(n) = (1/2)*(3-(-1)^n-2*(-1)^((2*n-1+(-1)^n)/4));
also a(n) = (1/2)*(3-(-1)^n-2*sin(Pi/4*(2n+1+(-1)^n))).
G.f.: (3x^3+2x^2+x)/(1-x^4). - Hieronymus Fischer, May 29 2007
From Hieronymus Fischer, Jun 11 2007: (Start)
Trigonometric representation: a(n)=2^2*(sin(n*Pi/4))^2*sum{1<=k<4, k*product{1<=m<4,m<>k, (sin((n-m)*Pi/4))^2}}. Clearly, the squared terms may be replaced by their absolute values '|.|'.
Complex representation: a(n)=1/4*(1-r^n)*sum{1<=k<4, k*product{1<=m<4,m<>k, (1-r^(n-m))}} where r=exp(Pi/2*i)=i=sqrt(-1). All these formulas can be easily adapted to represent any periodic sequence.
a(n) = 6 - a(n-1) - a(n-2) - a(n-3) for n > 2. - Reinhard Zumkeller, Apr 13 2008
a(n) = 3/2 + cos((n+1)*Pi)/2 + sqrt(2)*cos((2*n+3)*Pi/4). - Jaume Oliver Lafont, Dec 05 2008
From Hieronymus Fischer, Jan 04 2013: (Start)
a(n) = floor(41/3333*10^(n+1)) mod 10.
a(n) = floor(19/85*4^(n+1)) mod 4. (End)
E.g.f.: 2*sinh(x) - sin(x) + cosh(x) - cos(x). - Stefano Spezia, Apr 20 2021
From Nicolas Bělohoubek, May 30 2024: (Start)
a(n) = (2*a(n-1)-1)*(2-a(n-2)) for n > 1.
a(n) = (2*a(n-1)^2+1)*(3-a(n-1))/3 for n > 0. (End)
Extensions
First to third formulas re-edited for better readability by Hieronymus Fischer, Dec 05 2011
Incorrect g.f. removed by Georg Fischer, May 18 2019
Comments