OFFSET
0,3
COMMENTS
This sequence has connections with A109812; each term (except the first) has no 1 bit in common with some prior term.
This sequence is a permutation of the natural numbers. [Proof: The first term divisible by a given power of 2, 2^k say, is 2^k itself, and for k >= 3, it is immediately followed by the smallest missing number. Since there are infinitely many powers of 2, every number will eventually appear. - N. J. A. Sloane, May 17 2022]
An alternative and equivalent definition: a(0)=0, a(1)=1. For k >= 1, a(2*k) and a(2*k+1) are the two smallest numbers not yet in the sequence whose binary expansions have no 1's in common with the binary expansion of a(k). - N. J. A. Sloane, May 17 2022
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..10000
Rémy Sigrist, C++ program
EXAMPLE
The initial terms a(n), alongside the binary expansions of a(n) and a(floor(n/2)), are:
n a(n) bin(a(n)) bin(a(floor(n/2)))
-- ---- --------- ------------------
0 0 0 0
1 1 1 0
2 2 10 1
3 4 100 1
4 5 101 10
5 8 1000 10
6 3 11 100
7 9 1001 100
8 10 1010 101
9 16 10000 101
10 6 110 1000
11 7 111 1000
12 12 1100 11
PROG
(C++) See Links section.
(Python)
from itertools import count, islice
def agen(): # generator of terms
alst = [0, 1]; aset = {0, 1}; yield from alst
mink = 2
for n in count(2):
ahalf, k = alst[n//2], mink
while k in aset or k&ahalf: k += 1
alst.append(k); aset.add(k); yield k
while mink in aset: mink += 1
print(list(islice(agen(), 67))) # Michael S. Branicky, May 17 2022
CROSSREFS
KEYWORD
AUTHOR
Rémy Sigrist, Apr 04 2022
STATUS
approved