A168427 a(n) = 3^n mod 30.
1, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27, 21, 3, 9, 27
Offset: 0
Links
- Vincenzo Librandi, Table of n, a(n) for n = 0..1000
- Index entries for linear recurrences with constant coefficients, signature (1,-1,1).
Crossrefs
Cf. A001148.
Programs
-
Mathematica
PowerMod[3,Range[0,90],30] (* Harvey P. Dale, Nov 04 2011 *)
-
PARI
a(n)=lift(Mod(3,30)^n) \\ Charles R Greathouse IV, Mar 22 2016
-
Python
def A168427(n): return (21,3,9,27)[n&3] if n else 1 # Chai Wah Wu, Jan 22 2023
-
Sage
[power_mod(3,n,30) for n in range(0, 88)] #
Formula
From Chai Wah Wu, Jan 22 2023: (Start)
a(n) = a(n-1) - a(n-2) + a(n-3) for n > 3.
G.f.: (-20*x^3 - 7*x^2 - 2*x - 1)/((x - 1)*(x^2 + 1)). (End)