OFFSET
0,2
LINKS
G. C. Greubel, Table of n, a(n) for n = 0..1000
Index entries for linear recurrences with constant coefficients, signature (-1,-1,1,1,1).
FORMULA
a(n) = 2*floor(n/3) + 1 if (n mod 3) = 0, -(2*floor(n/3) + 3) if (n mod 3) = 1 and 0 if (n mod 3) = 2. - G. C. Greubel, Jun 16 2021
a(n) = (2*floor((n+5)/3)-1)*sign((n + 1) mod 3)*(-1)^(n mod 3). - Wesley Ivan Hurt, Jan 02 2022
MATHEMATICA
a[n_]:= a[n]= If[Mod[n, 3]==0, 2*Floor[n/3] +1, If[Mod[n, 3]==1, -(2*Floor[n/3] +3), 0]]; Table[a[n], {n, 0, 100}] (* G. C. Greubel, Jun 16 2021 *)
PROG
(Magma) R<x>:=PowerSeriesRing(Integers(), 100); Coefficients(R!( (1-2*x-2*x^2-x^3)/(1+x+x^2-x^3-x^4-x^5) )); // G. C. Greubel, Jun 16 2021
(Sage)
def A138188(n):
if (n%3==0): return 2*(n//3) +1
elif (n%3==1): return -(2*(n//3) +3)
else: return 0
[A138188(n) for n in (0..100)] # G. C. Greubel, Jun 16 2021
CROSSREFS
KEYWORD
easy,sign
AUTHOR
Paul Barry, Mar 04 2008
STATUS
approved