A332056 a(1) = 1, then a(n+1) = a(n) - (-1)^a(n) Sum_{k=1..n} a(k): if a(n) is odd, add the partial sum, else subtract.
1, 2, -1, 1, 4, -3, 1, 6, -5, 1, 8, -7, 1, 10, -9, 1, 12, -11, 1, 14, -13, 1, 16, -15, 1, 18, -17, 1, 20, -19, 1, 22, -21, 1, 24, -23, 1, 26, -25, 1, 28, -27, 1, 30, -29, 1, 32, -31, 1, 34, -33, 1, 36, -35, 1, 38, -37, 1, 40, -39
Offset: 1
Keywords
Examples
a(1) = 1 is odd, so we add the partial sum (so far equal to a(1)) to get the next term, a(2) = 2. Now a(2) = 2 is even, so we subtract the partial sum 1 + 2 = 3 to get a(3) = -1. And so on.
Links
- Eric Angelini, Re: Add or subtract my cumulative sum of terms, SeqFan list, Feb 24 2020.
- Index entries for linear recurrences with constant coefficients, signature (-1,-1,1,1,1).
Crossrefs
See A332057 for the partial sums.
Programs
-
PARI
s=-a=1; vector(100,n, a-=(-1)^a*s+=a)
-
PARI
apply( {A332056(n)=[1-n\3*2,1,n\/3*2][n%3+1]}, [1..99])
Formula
a(3k-2) = 1, a(3k-1) = 2k, a(3k) = 1 - 2k, for all k >= 1.
From Colin Barker, Feb 25 2020: (Start)
G.f.: x*(1 + x)*(1 + 2*x + x^3) / ((1 - x)*(1 + x + x^2)^2).
a(n) = -a(n-1) - a(n-2) + a(n-3) + a(n-4) + a(n-5) for n>5.
(End)
Comments