OFFSET
0,2
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (1,-1,1).
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
KEYWORD
nonn,easy
AUTHOR
Zerinvary Lajos, Nov 25 2009
STATUS
approved