A070432 Period 4: repeat [0, 1, 4, 1]; a(n) = n^2 mod 8.
0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0
Offset: 0
Examples
G.f. = x + 4*x^2 + x^3 + x^5 + 4*x^6 + x^7 + x^9 + 4*x^10 + x^11 + x^13 + ...
Links
- Index entries for linear recurrences with constant coefficients, signature (0,0,0,1). - _R. J. Mathar_, Apr 20 2010
Programs
-
Magma
&cat [[0, 1, 4, 1]^^30]; // Wesley Ivan Hurt, Dec 21 2016
-
Maple
seq(n mod 2 + 4*floor(((n+1) mod 4)/3), n = 0..200) # Gary Detlefs, Dec 29 2011
-
Mathematica
Table[Mod[n^2, 8], {n, 0, 99}] (* Vladimir Joseph Stephan Orlovsky, Apr 21 2011 *) Mod[Range[0, 99]^2, 8] (* Alonso del Arte, Mar 20 2015 *)
-
PARI
a(n)=n^2%8 \\ Charles R Greathouse IV, Oct 07 2015
Formula
From R. J. Mathar, Apr 20 2010: (Start)
a(n) = a(n-4) for n > 3.
G.f.: -x*(1+4*x+x^2) / ( (x-1)*(1+x)*(x^2+1) ). (End)
Dirichlet g.f.: zeta(s)*(1 + 4*2^(-s))*(1 - 2^(-s)). - R. J. Mathar, Mar 10 2011
a(n) = (n mod 2) + 4*floor(((n+1) mod 4)/3). - Gary Detlefs, Dec 29 2011
From Wesley Ivan Hurt, Mar 19 2015: (Start)
a(n) = (((n+1) mod 4) - 1)^2.
a(n) = (1 + (-1)^n - 2(-1)^((2n + 1 - (-1)^n)/4))^2/4. (End)
E.g.f.: 2*cosh(x) + sinh(x) - 2*cos(x). - G. C. Greubel, Mar 22 2016
a(n) = (3 + cos(n*Pi) - 4*cos(n*Pi/2))/2. - Wesley Ivan Hurt, Dec 21 2016
a(n) = a(-n) for all n in Z. - Michael Somos, Dec 22 2016
Comments