%I #56 Dec 14 2023 05:06:16
%S 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,
%T 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,
%U 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
%N Period 4: repeat [0, 1, 4, 1]; a(n) = n^2 mod 8.
%C Multiplicative with a(2) = 4, a(2^e) = 0 if e >= 2, a(p^e) = 1 otherwise. - _David W. Wilson_, Jun 12 2005
%H <a href="/index/Rec#order_04">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,0,1). - _R. J. Mathar_, Apr 20 2010
%F From _R. J. Mathar_, Apr 20 2010: (Start)
%F a(n) = a(n-4) for n > 3.
%F G.f.: -x*(1+4*x+x^2) / ( (x-1)*(1+x)*(x^2+1) ). (End)
%F Dirichlet g.f.: zeta(s)*(1 + 4*2^(-s))*(1 - 2^(-s)). - _R. J. Mathar_, Mar 10 2011
%F a(n) = (n mod 2) + 4*floor(((n+1) mod 4)/3). - _Gary Detlefs_, Dec 29 2011
%F From _Wesley Ivan Hurt_, Mar 19 2015: (Start)
%F a(n) = (((n+1) mod 4) - 1)^2.
%F a(n) = (1 + (-1)^n - 2(-1)^((2n + 1 - (-1)^n)/4))^2/4. (End)
%F E.g.f.: 2*cosh(x) + sinh(x) - 2*cos(x). - _G. C. Greubel_, Mar 22 2016
%F a(n) = (3 + cos(n*Pi) - 4*cos(n*Pi/2))/2. - _Wesley Ivan Hurt_, Dec 21 2016
%F a(n) = a(-n) for all n in Z. - _Michael Somos_, Dec 22 2016
%e G.f. = x + 4*x^2 + x^3 + x^5 + 4*x^6 + x^7 + x^9 + 4*x^10 + x^11 + x^13 + ...
%p seq(n mod 2 + 4*floor(((n+1) mod 4)/3), n = 0..200) # _Gary Detlefs_, Dec 29 2011
%t Table[Mod[n^2, 8], {n, 0, 99}] (* _Vladimir Joseph Stephan Orlovsky_, Apr 21 2011 *)
%t Mod[Range[0, 99]^2, 8] (* _Alonso del Arte_, Mar 20 2015 *)
%o (PARI) a(n)=n^2%8 \\ _Charles R Greathouse IV_, Oct 07 2015
%o (Magma) &cat [[0, 1, 4, 1]^^30]; // _Wesley Ivan Hurt_, Dec 21 2016
%Y Cf. A070430, A070431.
%K nonn,easy,mult
%O 0,3
%A _N. J. A. Sloane_, May 12 2002