This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A332056 #30 Jul 31 2025 13:14:17 %S A332056 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, %T A332056 -17,1,20,-19,1,22,-21,1,24,-23,1,26,-25,1,28,-27,1,30,-29,1,32,-31,1, %U A332056 34,-33,1,36,-35,1,38,-37,1,40,-39 %N 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. %C A332056 The terms display a 3-quasiperiodic pattern (1, 2m, 1-2m), m = 1, 2, 3, ... %C A332056 Conjecture from Barker confirmed by recurrence formula. - _Ray Chandler_, Jul 31 2025 %H A332056 Eric Angelini, <a href="https://web.archive.org/web/*/http://list.seqfan.eu/oldermail/seqfan/2020-February/020509.html">Re: Add or subtract my cumulative sum of terms</a>, SeqFan list, Feb 24 2020. %H A332056 <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (-1,-1,1,1,1). %F A332056 a(3k-2) = 1, a(3k-1) = 2k, a(3k) = 1 - 2k, for all k >= 1. %F A332056 From _Colin Barker_, Feb 25 2020: (Start) %F A332056 G.f.: x*(1 + x)*(1 + 2*x + x^3) / ((1 - x)*(1 + x + x^2)^2). %F A332056 a(n) = -a(n-1) - a(n-2) + a(n-3) + a(n-4) + a(n-5) for n>5. %F A332056 (End) %e A332056 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. %e A332056 Now a(2) = 2 is even, so we subtract the partial sum 1 + 2 = 3 to get a(3) = -1. %e A332056 And so on. %o A332056 (PARI) s=-a=1; vector(100,n, a-=(-1)^a*s+=a) %o A332056 (PARI) apply( {A332056(n)=[1-n\3*2,1,n\/3*2][n%3+1]}, [1..99]) %Y A332056 See A332057 for the partial sums. %K A332056 sign %O A332056 1,2 %A A332056 _Eric Angelini_ and _M. F. Hasler_, Feb 24 2020