login
a(n) = 2^n mod 31.
2

%I #59 Sep 08 2022 08:46:15

%S 1,2,4,8,16,1,2,4,8,16,1,2,4,8,16,1,2,4,8,16,1,2,4,8,16,1,2,4,8,16,1,

%T 2,4,8,16,1,2,4,8,16,1,2,4,8,16,1,2,4,8,16,1,2,4,8,16,1,2,4,8,16,1,2,

%U 4,8,16,1,2,4,8,16,1,2,4,8,16,1,2,4,8,16,1

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

%D Continued fraction expansion of (1651+sqrt(3236405))/2386. - _Bruno Berselli_, Mar 31 2016

%H Muniru A Asiru, <a href="/A269266/b269266.txt">Table of n, a(n) for n = 0..1000</a>

%H <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,0,0,1).

%F G.f.: (1 + 2*x + 4*x^2 + 8*x^3 + 16*x^4)/(1 - x^5).

%F a(n) = a(n-5).

%F a(n) = 2^(n mod 5). - _Bruno Berselli_, Mar 31 2016

%t PowerMod[2, Range[0, 100], 31]

%o (Magma) [Modexp(2, n, 31): n in [0..100]];

%o (Magma) &cat [[1,2,4,8,16]^^20] // _Bruno Berselli_, Mar 31 2016

%o (PARI) a(n)=2^(n%5) \\ _Charles R Greathouse IV_, Mar 31 2016

%o (PARI) x='x+O('x^99); Vec((1+2*x+4*x^2+8*x^3+16*x^4)/(1-x^5)) \\ _Altug Alkan_, Mar 31 2016

%o (Sage) [2^mod(n,5) for n in (0..100)] # _Bruno Berselli_, Mar 31 2016

%o (Python) for n in range(0,100):print(2**n%31) # _Soumil Mandal_, Apr 03 2016

%o (Python) def A269266(n): return pow(2,n,31) # _Chai Wah Wu_, Jan 03 2022

%o (GAP) List([0..70],n->PowerMod(2,n,31)); # _Muniru A Asiru_, Jan 30 2019

%Y Cf. A201912 (11th row of the triangle).

%Y Cf. similar sequences of the type 2^n mod p, where p is a prime: A000034 (p=3), A070402 (p=5), A069705 (p=7), A036117 (p=11), A036118 (p=13), A062116 (p=17), A036120 (p=19), A070335 (p=23), A036122 (p=29), this sequence (p=31), A036124 (p=37), A070348 (p=41), A070349 (p=43), A070351 (p=47), A036128 (p=53), A036129 (p=59), A036130 (p=61), A036131 (p=67).

%K nonn,easy

%O 0,2

%A _Vincenzo Librandi_, Mar 31 2016