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 A354971 #54 Sep 06 2022 15:11:12 %S A354971 1,0,1,1,3,1,1,5,5,5,1,3,3,3,6,3,5,5,5,5,1,7,1,1,9,5,9,8,8,9,9,1,4,2, %T A354971 10,4,10,4,1,3,2,11,4,11,4,2,2,5,5,2,10,5,5,12,2,12,2,7,3,2,2,7,9,2,3, %U A354971 3,5,3,10,10,10,10,3,7,13,4,7,7,7,7,11 %N A354971 a(1)=1, a(2)=0; for n > 2, a(n) is the number of times a(n - 1 - a(n-1)) has appeared in the sequence. %C A354971 Conjecture: every positive integer eventually appears in the sequence. %C A354971 Conjecture: The longest run of same, consecutive a(n) is 4 terms. %C A354971 A003056 can be generated using the same rules but starting with 0. %H A354971 Michael De Vlieger, <a href="/A354971/b354971.txt">Table of n, a(n) for n = 1..10000</a> %H A354971 Michael De Vlieger, <a href="/A354971/a354971.png">Log-log scatterplot of a(n)</a>, n = 1..2^16, showing records in red, first entries of other m in green, and the latest entries of m in blue. %H A354971 Neal Gersh Tolunsky, <a href="/A354971/a354971_3.png">Illustration of first 100 terms</a> %e A354971 For n=9, a(9) is the number of times a(9 - 1 - a(9-1)) = a(8 - a(8)) = a(3) = 1 has appeared in the sequence, so a(9)=5. %t A354971 nn = 2^20; c[_] = 0; a[1] = c[0] = c[1] = 1; a[2] = j = 0; Do[k = c[a[n - j - 1]]; a[n] = j = k; c[k]++, {n, 3, nn}]; Array[a, nn] (* _Michael De Vlieger_, Jun 25 2022 *) %o A354971 (MATLAB) function a = A354971( max_n ) %o A354971 a = [1 0]; c = zeros(1,max_n); c(1:2) = [1 1]; %o A354971 for n = 3:max_n %o A354971 m = a(n-1-a(n-1))+1; %o A354971 a = [a c(m)]; %o A354971 c(c(m)+1) = c(c(m)+1)+1; %o A354971 end %o A354971 end % _Thomas Scheuerle_, Jun 15 2022 %o A354971 (PARI) { nb = [0]; for (n=1, #a=vector(81), print1 (a[n] = if (n==1, 1, n==2, 0, nb[1+a[n-1-a[n-1]]])", "); if (#nb < 1+a[n], nb = concat(nb, vector(#nb))); nb[1+a[n]]++) } \\ _Rémy Sigrist_, Jun 18 2022 %o A354971 (Python) %o A354971 from collections import Counter %o A354971 from itertools import count, islice %o A354971 def agen(): %o A354971 a = [None, 1, 0]; inventory = Counter(a); yield from a[1:] %o A354971 for n in count(3): %o A354971 c = inventory[a[n-1-a[n-1]]] %o A354971 a.append(c); inventory.update([c]); yield c %o A354971 print(list(islice(agen(), 81))) # _Michael S. Branicky_, Jun 18 2022 %Y A354971 Cf. A003056, A329985 %K A354971 nonn,easy %O A354971 1,5 %A A354971 _Neal Gersh Tolunsky_, Jun 14 2022