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 A191598 #9 Nov 13 2024 17:00:41 %S A191598 1,2,4,3,6,5,10,7,8,9,18,11,12,13,14,15,16,17,34,19,20,21,22,23,24,25, %T A191598 26,27,28,29,30,31,32,33,66,35,36,37,38,39,40,41,42,43,44,45,46,47,48, %U A191598 49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,130 %N A191598 a(1)=1. Then, if the first n terms contain all the numbers 1 to n, a(n+1)=2*a(n), otherwise a(n+1) is the smallest number not already in the sequence. %H A191598 Michael S. Branicky, <a href="/A191598/b191598.txt">Table of n, a(n) for n = 1..10000</a> %e A191598 There are no gaps with just one term, so we double to get a(2)=2. Still no gaps, so we double again to get a(3)=4. Now 3 has not appeared yet, so a(4)=3. The sequence is compact again, so we double to get a(5)=6. %o A191598 (Python) %o A191598 from itertools import count, islice %o A191598 def agen(): # generator of terms %o A191598 an, aset, m = 1, {1}, 2 %o A191598 for n in count(1): %o A191598 yield an %o A191598 an = 2*an if m > n else m %o A191598 aset.add(an) %o A191598 while m in aset: m += 1 %o A191598 print(list(islice(agen(), 67))) # _Michael S. Branicky_, Nov 13 2024 %K A191598 nonn,easy %O A191598 1,2 %A A191598 _Greg Knowles_, Jun 08 2011