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 A362373 #49 Jun 21 2025 00:45:02 %S A362373 0,1,3,2,6,11,4,11,19,10,9,12,11,24,38,23,7,24,42,8,28,49,27,15,30,5, %T A362373 31,22,20,49,24,26,58,25,59,94,130,93,14,53,13,54,18,61,17,62,16,63, %U A362373 111,50,49,100,48,39,41,96,40,97,32,34,94 %N A362373 a(0) = 0; for n > 0, if n appears in the sequence then a(n) is the sum of the indices of all previous appearances of n. Otherwise a(n) = a(n-1) - n if nonnegative and not already in the sequence, otherwise a(n) = a(n-1) + n. %C A362373 Conjecture: All nonnegative integers appear in this sequence. - _Yifan Xie_, Apr 24 2023 %H A362373 Michael De Vlieger, <a href="/A362373/b362373.txt">Table of n, a(n) for n = 0..16384</a> %H A362373 Michael De Vlieger, <a href="/A362373/a362373.png">Log log scatterplot of a(n)</a>, n = 1..2^14. %H A362373 Michael De Vlieger, <a href="/A362373/a362373_1.png">Log log scatterplot of a(n)</a>, n = 1..2^20 %e A362373 a(2) = 3 = n, thus a(3) = 2. %e A362373 a(5) = 11, as 5 has not previously appeared in the sequence, but a(4) - 5 = 1 has, thus a(5) = a(4) + 5 = 6 + 5 = 11. %e A362373 a(5) and a(7) = 11, and 5 + 7 = 12, thus a(11) = 12. %t A362373 nn = 120; c[_] := 0; j = a[0] = 0; Do[If[# > 0, Set[k, #], If[And[n <= j, c[#] == 0], Set[k, #], Set[k, j + n]] &[j - n] ] &[c[n]]; c[k] += n; Set[{a[n], j}, {k, k}], {n, nn}]; Array[a, nn, 0] (* _Michael De Vlieger_, Apr 19 2023 *) %o A362373 (Python) %o A362373 from itertools import count, islice %o A362373 def A362373_gen(): # generator of terms %o A362373 a, ndict = 0, {0:0} %o A362373 yield 0 %o A362373 for n in count(1): %o A362373 yield (a:= ndict[n] if n in ndict else (a-n if a>=n and a-n not in ndict else a+n)) %o A362373 ndict[a] = ndict.get(a,0)+n %o A362373 A363373_list = list(islice(A362373_gen(),30)) # _Chai Wah Wu_, Jun 29 2023 %Y A362373 Cf. A005132, A340612. %K A362373 nonn,look,easy %O A362373 0,3 %A A362373 _Kelvin Voskuijl_, Apr 17 2023