A008959 Final digit of squares: a(n) = n^2 mod 10.
0, 1, 4, 9, 6, 5, 6, 9, 4, 1, 0, 1, 4, 9, 6, 5, 6, 9, 4, 1, 0, 1, 4, 9, 6, 5, 6, 9, 4, 1, 0, 1, 4, 9, 6, 5, 6, 9, 4, 1, 0, 1, 4, 9, 6, 5, 6, 9, 4, 1, 0, 1, 4, 9, 6, 5, 6, 9, 4, 1, 0, 1, 4, 9, 6, 5, 6, 9, 4, 1, 0, 1, 4, 9, 6, 5, 6, 9, 4, 1, 0, 1, 4, 9, 6, 5, 6, 9, 4, 1, 0, 1, 4, 9, 6, 5, 6, 9, 4, 1, 0
Offset: 0
Links
- Harvey P. Dale, Table of n, a(n) for n = 0..1000
- Index entries for sequences related to final digits of numbers
- Index entries for linear recurrences with constant coefficients, signature (0,0,0,0,0,0,0,0,0,1).
Crossrefs
Programs
-
Magma
[0] cat [Intseq(n^2)[1]: n in [1..80]]; // Bruno Berselli, Feb 14 2013
-
Magma
[n^2 - 10*Floor(n^2/10): n in [0..80]]; // Vincenzo Librandi, Jun 16 2015
-
Maple
A008959:=n->(n^2 mod 10); seq(A008959(n), n=0..50); # Wesley Ivan Hurt, Jun 06 2014
-
Mathematica
Table[Mod[n^2,10],{n,0,200}] (* Vladimir Joseph Stephan Orlovsky, Apr 21 2011 *) PowerMod[Range[0,80],2,10] (* or *) LinearRecurrence[{0,0,0,0,0,0,0,0,0,1},{0,1,4,9,6,5,6,9,4,1},120] (* Harvey P. Dale, Oct 16 2012 *)
-
PARI
a(n)=n^2%10 \\ Charles R Greathouse IV, Sep 24 2015
-
Sage
[power_mod(n,2,10) for n in range(0, 81)] # Zerinvary Lajos, Nov 06 2009
Formula
Periodic with period 10. - Franklin T. Adams-Watters, Mar 13 2006
a(n) = 4.5 - (1 + 5^(1/2))*cos(Pi*n/5) + (-1 - 3/5*5^(1/2))*cos(2*Pi*n/5) + (5^(1/2) - 1)*cos(3*Pi*n/5) + (-1 + 3/5*5^(1/2))*cos(4*Pi*n/5) - 0.5*(-1)^n. - Richard Choulet, Dec 12 2008
G.f.: (x^9+4*x^8+9*x^7+6*x^6+5*x^5+6*x^4+9*x^3+4*x^2+x)/(-x^10+1). - Colin Barker, Aug 14 2012
a(n) = n^2 - 10*floor(n^2/10). - Wesley Ivan Hurt, Jun 12 2013
a(n) = A033569(n+3) mod 10. - Wesley Ivan Hurt, Dec 06 2014
a(n) = n^k mod 10; for k > 0 where k mod 4 = 2. - Doug Bell, Jun 15 2015
Comments