%I #59 Dec 14 2023 05:20:07
%S 1,3,4,2,1,3,4,2,1,3,4,2,1,3,4,2,1,3,4,2,1,3,4,2,1,3,4,2,1,3,4,2,1,3,
%T 4,2,1,3,4,2,1,3,4,2,1,3,4,2,1,3,4,2,1,3,4,2,1,3,4,2,1,3,4,2,1,3,4,2,
%U 1,3,4,2,1,3,4,2,1,3,4,2,1,3,4,2,1,3,4,2,1,3,4,2,1,3,4,2,1,3,4,2,1
%N a(n) = 3^n mod 5; or period 4, repeat [1, 3, 4, 2].
%C Residues mod 5 of Lucas numbers: for n>=1, a(n-1) = A000032(n) mod 5. - _Clark Kimberling_, Aug 28 2008
%H G. C. Greubel, <a href="/A070352/b070352.txt">Table of n, a(n) for n = 0..1000</a>
%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (1,-1,1).
%F From _R. J. Mathar_, Apr 13 2010: (Start)
%F a(n) = a(n-1) - a(n-2) + a(n-3) for n>2.
%F G.f.: (1+2*x+2*x^2) / ((1-x)*(1+x^2)). (End)
%F a(n) = 2^(3*n) mod 5. - _Gary Detlefs_, May 18 2014
%F E.g.f.: (1/2)*(5*exp(x) + sin(x) - 3*cos(x)). - _G. C. Greubel_, Mar 11 2016
%F a(n) = a(n-4) for n>3. - _Wesley Ivan Hurt_, Jul 09 2016
%p seq(op([1, 3, 4, 2]), n=0..50); # _Wesley Ivan Hurt_, Jul 09 2016
%t Table[PowerMod[3, n, 5], {n, 0, 200}] (* _Vladimir Joseph Stephan Orlovsky_, Jun 10 2011 *)
%o (Sage) [power_mod(2,-n,5) for n in range(0, 101)] # _Zerinvary Lajos_, Jun 08 2009
%o (Magma) &cat [[1, 3, 4, 2]^^27]; // _Bruno Berselli_, Dec 10 2015
%o (Magma) [Modexp(3, n, 5): n in [0..100]]; // _Bruno Berselli_, Mar 23 2016
%o (PARI) a(n) = lift(Mod(3, 5)^n); \\ _Michel Marcus_, Mar 16 2016
%Y Cf. A000032. - _Clark Kimberling_, Aug 28 2008
%K nonn,easy
%O 0,2
%A _N. J. A. Sloane_, May 12 2002