%I #37 Dec 27 2023 08:31:50
%S 1,8,4,2,6,8,4,2,6,8,4,2,6,8,4,2,6,8,4,2,6,8,4,2,6,8,4,2,6,8,4,2,6,8,
%T 4,2,6,8,4,2,6,8,4,2,6,8,4,2,6,8,4,2,6,8,4,2,6,8,4,2,6,8,4,2,6,8,4,2,
%U 6,8,4,2,6,8,4,2,6,8,4,2,6
%N Final digit of 8^n.
%H Vincenzo Librandi, <a href="/A014391/b014391.txt">Table of n, a(n) for n = 0..1000</a>
%H <a href="/index/Fi#final">Index entries for sequences related to final digits of numbers</a>
%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (1,-1,1).
%F a(n) = 8^n mod 10. [_Zerinvary Lajos_, Nov 27 2009]
%F G.f.: -(7*x - 3*x^2 + 5*x^3 + 1)/ ((x - 1)*(1 + x^2)). [_R. J. Mathar_, Apr 20 2010]
%F a(n) = +a(n-1) -a(n-2) +a(n-3). [_R. J. Mathar_, Apr 20 2010]
%t Table[PowerMod[8, n, 10], {n, 0, 200}] (* _Vladimir Joseph Stephan Orlovsky_, Jun 10 2011 *)
%t LinearRecurrence[{1,-1,1},{1,8,4,2},100] (* _Harvey P. Dale_, Jul 01 2019 *)
%o (Sage) [power_mod(8,n,10)for n in range(0,105)] # _Zerinvary Lajos_, Nov 27 2009
%o (PARI) a(n)=lift(Mod(8,10)^n) \\ _Charles R Greathouse IV_, Dec 29 2012
%o (Magma) [Modexp(8, n, 10): n in [0..100]]; // _Vincenzo Librandi_, Jun 30 2016
%K nonn,easy
%O 0,2
%A _N. J. A. Sloane_.