login
A168427
a(n) = 3^n mod 30.
1
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,2
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)
MATHEMATICA
PowerMod[3, Range[0, 90], 30] (* Harvey P. Dale, Nov 04 2011 *)
PROG
(Sage) [power_mod(3, n, 30) for n in range(0, 88)] #
(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
CROSSREFS
Cf. A001148.
Sequence in context: A321542 A321540 A036123 * A070344 A070357 A131137
KEYWORD
nonn,easy
AUTHOR
Zerinvary Lajos, Nov 25 2009
STATUS
approved