Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #32 May 26 2024 08:20:54
%S 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 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 29,15,7,30,31,16,8,32,33,17,9,4,34,35,2,1,18,19,36
%N 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 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 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 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 Michael S. Branicky, <a href="/A372704/b372704.txt">Table of n, a(n) for n = 1..10000</a>
%H Neal Gersh Tolunsky, <a href="/A372704/a372704.png">Graph of first differences of first 20000 terms</a>.
%e a(n) ban 1 2 3 4 5 6 ...
%e 1 | | | | | |
%e 2 | | | | | |
%e 1 | x | | | |
%e 2 x | | | | |
%e 1 | x | | | |
%e 3 x x | | | |
%e 2 x | x | | |
%e 1 | x x | | |
%e 4 x x x | | |
%e 5 x x x x | |
%e 6 x x x x x |
%e 2 x | | x x x
%e 1 | x | x x x
%e 3 x x x x x x
%o (Python)
%o from collections import Counter
%o from itertools import count, islice
%o def agen(): # generator of terms
%o an, ban, occurs = 1, {1: 1}, Counter([1])
%o for n in count(2):
%o yield an
%o an = next(k for k in count(1) if k not in ban)
%o for k in list(ban):
%o if ban[k] > 1: ban[k] -= 1
%o else: del ban[k]
%o ban[an] = n - 1 - occurs[an]
%o occurs[an] += 1
%o print(list(islice(agen(), 75))) # _Michael S. Branicky_, May 10 2024
%Y Cf. A364603, A364604.
%K nonn
%O 1,2
%A _Neal Gersh Tolunsky_, May 10 2024
%E a(20) and beyond from _Michael S. Branicky_, May 10 2024