OFFSET
0,2
COMMENTS
Original definition: Unit digits of the nonzero, even squares.
This sequence is periodic with period <4,6,6,4,0> of length five. Hence, as the members of each cycle sum to 20, the terms satisfy the fifth-order homogeneous recurrence a(n)=a(n-5) and the fourth-order inhomogeneous recurrence a(n) = 20 - a(n-1) - a(n-2) - a(n-3) - a(n-4).
LINKS
Index entries for linear recurrences with constant coefficients, signature (0,0,0,0,1).
FORMULA
a(n) = mod(4*n^2,10).
G.f.: (4*x+6*x^2+6*x^3+4*x^4+0*x^5)/(1-x^5) (note that the coefficients of x in the numerator are the terms that constitute the periodic cycle of the sequence).
G.f. -2*x*(1+x)*(2*x^2+x+2) / ( (x-1)*(1+x+x^2+x^3+x^4) ). - R. J. Mathar, Oct 08 2011
a(n) = 4+(16*cos(2*Pi/5)-24*cos(Pi/5))*cos(2*Pi*n/5)/5 +(24*cos(2*Pi/5)-16*cos(Pi/5))*cos(4*Pi*n/5)/5. - R. J. Mathar, Oct 08 2011
EXAMPLE
a(5) = (2*5)^2 mod 10 = 100 mod 10 = 0.
MATHEMATICA
Mod[4#^2, 10] &/@Range[50]
PadRight[{}, 120, {0, 4, 6, 6, 4}] (* Harvey P. Dale, Sep 27 2015 *)
PROG
(PARI) a(n)=4*n^2%10 \\ Charles R Greathouse IV, Jun 19 2011
(PARI) a(n)=[0, 4, 6, 6, 4][n%5+1] \\ M. F. Hasler, Jun 11 2011
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Ant King, Jun 18 2011
STATUS
approved