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 A372704 #32 May 26 2024 08:20:54 %S A372704 1,2,1,2,1,3,2,1,4,5,6,2,1,3,7,8,9,4,10,5,2,1,6,11,12,13,3,14,15,7,16, %T A372704 8,17,9,4,18,19,2,1,5,10,20,21,22,6,23,24,11,25,12,26,3,13,27,28,14, %U A372704 29,15,7,30,31,16,8,32,33,17,9,4,34,35,2,1,18,19,36 %N A372704 a(1)=1; a(2)=2; for n>1, this is the lexicographically earliest sequence such that, following each occurrence of a(n), a(n) is banned for the next k terms, where k is the number of terms prior to a(n) that are not equal to a(n). %C A372704 1 occurs immediately after its ban ends so that the i-th occurrence of a(n) = 1, for i >= 2, is at n = 2^(i-2) + i = A052968(i-1). %C A372704 2 occurs immediately after its ban ends, since it turns out that's immediately before the ban on 1 ends, so the i-th occurrence of a(n) = 2 is at n = 2^(i-1) + i = A005126(i-1). %C A372704 If the definition is changed so that k is the number of terms in the sequence thus far equal to a(n) (rather than unequal), this becomes A002260 without the initial 1. %H A372704 Michael S. Branicky, <a href="/A372704/b372704.txt">Table of n, a(n) for n = 1..10000</a> %H A372704 Neal Gersh Tolunsky, <a href="/A372704/a372704.png">Graph of first differences of first 20000 terms</a>. %e A372704 a(n) ban 1 2 3 4 5 6 ... %e A372704 1 | | | | | | %e A372704 2 | | | | | | %e A372704 1 | x | | | | %e A372704 2 x | | | | | %e A372704 1 | x | | | | %e A372704 3 x x | | | | %e A372704 2 x | x | | | %e A372704 1 | x x | | | %e A372704 4 x x x | | | %e A372704 5 x x x x | | %e A372704 6 x x x x x | %e A372704 2 x | | x x x %e A372704 1 | x | x x x %e A372704 3 x x x x x x %o A372704 (Python) %o A372704 from collections import Counter %o A372704 from itertools import count, islice %o A372704 def agen(): # generator of terms %o A372704 an, ban, occurs = 1, {1: 1}, Counter([1]) %o A372704 for n in count(2): %o A372704 yield an %o A372704 an = next(k for k in count(1) if k not in ban) %o A372704 for k in list(ban): %o A372704 if ban[k] > 1: ban[k] -= 1 %o A372704 else: del ban[k] %o A372704 ban[an] = n - 1 - occurs[an] %o A372704 occurs[an] += 1 %o A372704 print(list(islice(agen(), 75))) # _Michael S. Branicky_, May 10 2024 %Y A372704 Cf. A364603, A364604. %K A372704 nonn %O A372704 1,2 %A A372704 _Neal Gersh Tolunsky_, May 10 2024 %E A372704 a(20) and beyond from _Michael S. Branicky_, May 10 2024