login
a(n) = 2^n mod 5.
7

%I #47 Dec 14 2023 05:06:27

%S 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,

%T 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,

%U 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

%N a(n) = 2^n mod 5.

%C Periodic with period 4: [1, 2, 4, 3]. - _Washington Bomfim_, Nov 23 2010

%H G. C. Greubel, <a href="/A070402/b070402.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).

%F G.f.: (1 + x + 3*x^2) / ((1-x)*(1+x^2)). (End)

%F From _Washington Bomfim_, Nov 23 2010: (Start)

%F a(n) = 1 + (15*r^2 - 5*r - 4*r^3)/6, where r = n mod 4.

%F a(n) = A000689(n) - 5*floor(((n-1) mod 4)/2) for n>0. (End)

%F E.g.f.: (1/2)*(5*exp(x) - 3*cos(x) - sin(x)). - _G. C. Greubel_, Mar 19 2016

%p A070402 := proc(n) op((n mod 4)+1,[1,2,4,3]) ; end proc: # _R. J. Mathar_, Feb 05 2011

%t 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 *)

%t PowerMod[2,Range[0,120],5] (* _Harvey P. Dale_, Sep 16 2020 *)

%o (Sage) [power_mod(2,n,5) for n in range(0, 105)] # _Zerinvary Lajos_, Jun 08 2009

%o (PARI) for(n=0, 80, x=n%4; print1(1 + (15*x^2 -5*x -4*x^3)/6, ", ")) \\ _Washington Bomfim_, Nov 23 2010

%o (Magma) [Modexp(2, n, 5): n in [0..100]]; // _Bruno Berselli_, Mar 23 2016

%o (GAP) List([0..83],n->PowerMod(2,n,5)); # _Muniru A Asiru_, Feb 01 2019

%Y Cf. A173635.

%K nonn,easy

%O 0,2

%A _N. J. A. Sloane_, May 12 2002