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 A332058 #27 Dec 23 2024 14:53:46 %S A332058 1,2,-1,3,10,2,-8,-26,-52,-85,-39,19,87,170,79,186,64,-68,-214,-367, %T A332058 -198,-385,-182,-396,-628,-876,-1145,-865,-566,-882,-1216,-1560,-1916, %U A332058 -2289,-1895,-1478,-1915,-1462,-1928,-2414,-2911,-2401 %N A332058 a(1) = 1; a(n+1) = a(n) +- (sum of digits of a(1) up to a(n)), with "+" when a(n) is odd, or "-" if even. %C A332058 The graph appears to have a shape similar to that of Mertens function A002321, with increasingly large "mountains" and "valleys": %C A332058 Successive record values of opposite sign are a(2) = 2, a(3) = -1, a(5) = 10, a(10) = -85, a(16) = 186, a(222) = -75573, a(391) = 26186, a(658) = -341791, a(987) = 134304, a(1831) = -1820815, a(2476) = 393048, a(2692) = -2089141, a(3321) = 1816290, a(6114) = -8650189, ... %H A332058 M. F. Hasler, <a href="/A332058/b332058.txt">Table of n, a(n) for n = 1..10000</a> %H A332058 Eric Angelini, <a href="https://web.archive.org/web/*/http://list.seqfan.eu/oldermail/seqfan/2020-February/020508.html">Re: Add or subtract my cumulative sum of digits</a>, SeqFan list, Feb 24 2020. %e A332058 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 A332058 Now a(2) = 2 is even, so we subtract the sum of the digits of a(1) and a(2), 1 + 2 = 3 to get a(3) = -1. %e A332058 Since a(3) = -1 is odd, we add the sum of the digits of a(1), a(2) and a(3), 1 + 2 + 1 = 4 to get a(4) = 3. %e A332058 And so on. %t A332058 Nest[Append[#, #[[-1]] + (2 Boole[OddQ@ #[[-1]] ] - 1)*Total[Flatten@ IntegerDigits[#]] ] &, {1}, 41] (* _Michael De Vlieger_, Feb 25 2020 *) %o A332058 (PARI) A332058_vec(N,a=1,s=-a)={vector(N,n, a-=(-1)^a*s+=sumdigits(a))} %o A332058 (Python) %o A332058 from itertools import count, islice %o A332058 def agen(): # generator of terms %o A332058 an, s = 1, 1 %o A332058 while True: %o A332058 yield an %o A332058 an = an + s if an&1 else an - s %o A332058 s += sum(map(int, str(abs(an)))) %o A332058 print(list(islice(agen(), 42))) # _Michael S. Branicky_, Oct 14 2024 %Y A332058 See A332056 for the variant considering sum of a(n) instead of digits. %K A332058 sign,base %O A332058 1,2 %A A332058 _Eric Angelini_ and _M. F. Hasler_, Feb 24 2020