A070402 a(n) = 2^n mod 5.
1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1, 2, 4, 3, 1
Offset: 0
Links
- G. C. Greubel, Table of n, a(n) for n = 0..1000
- Index entries for linear recurrences with constant coefficients, signature (1,-1,1).
Crossrefs
Cf. A173635.
Programs
-
GAP
List([0..83],n->PowerMod(2,n,5)); # Muniru A Asiru, Feb 01 2019
-
Magma
[Modexp(2, n, 5): n in [0..100]]; // Bruno Berselli, Mar 23 2016
-
Maple
A070402 := proc(n) op((n mod 4)+1,[1,2,4,3]) ; end proc: # R. J. Mathar, Feb 05 2011
-
Mathematica
PadRight[{}, 100, {1, 2, 4, 3}] (* or *) CoefficientList[Series[(1 + 2 x + 4 x^2 + 3 x^3) / (1 - x^4), {x, 0, 100}], x] (* Vincenzo Librandi, Mar 25 2016 *) PowerMod[2,Range[0,120],5] (* Harvey P. Dale, Sep 16 2020 *)
-
PARI
for(n=0, 80, x=n%4; print1(1 + (15*x^2 -5*x -4*x^3)/6, ", ")) \\ Washington Bomfim, Nov 23 2010
-
Sage
[power_mod(2,n,5) for n in range(0, 105)] # Zerinvary Lajos, Jun 08 2009
Formula
From R. J. Mathar, Apr 13 2010: (Start)
a(n) = a(n-1) - a(n-2) + a(n-3).
G.f.: (1 + x + 3*x^2) / ((1-x)*(1+x^2)). (End)
From Washington Bomfim, Nov 23 2010: (Start)
a(n) = 1 + (15*r^2 - 5*r - 4*r^3)/6, where r = n mod 4.
a(n) = A000689(n) - 5*floor(((n-1) mod 4)/2) for n>0. (End)
E.g.f.: (1/2)*(5*exp(x) - 3*cos(x) - sin(x)). - G. C. Greubel, Mar 19 2016
Comments