A001148 Final digit of 3^n.
1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1, 3, 9, 7, 1
Offset: 0
Links
Programs
-
Magma
[3^n mod 10: n in [0..150]]; // Vincenzo Librandi, Apr 12 2011
-
Mathematica
Table[PowerMod[3, n, 10], {n, 0, 200}] (* Vladimir Joseph Stephan Orlovsky, Jun 10 2011 *)
-
PARI
a(n)=[1, 3, 9, 7][n%4+1] \\ Charles R Greathouse IV, Dec 27 2012
-
Sage
[power_mod(3, n, 10) for n in range(0, 81)] # Zerinvary Lajos, Nov 24 2009
Formula
Periodic with period 4.
From R. J. Mathar, Apr 13 2010: (Start)
a(n) = a(n-1) - a(n-2) + a(n-3).
G.f.: (1+2*x+7*x^2)/ ((1-x) * (1+x^2)). (End)
a(n) = 5 - (2+i)*(-i)^n - (2-i)*i^n, where i is the imaginary unit. Also a(n) = A001903(A159966(n)). - Bruno Berselli, Feb 08 2011
a(0)=1, a(1)=3, a(n) = 10 - a(n-2). - Vincenzo Librandi, Feb 08 2011
Comments