Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Search: a354142 -id:a354142
     Sort: relevance | references | number | modified | created      Format: long | short | data
Lexicographically earliest sequence of distinct nonnegative integers such that for any n >= 0, a(n) AND a(floor(n/2)) = 0 (where AND denotes the bitwise AND operator).
+10
7
0, 1, 2, 4, 5, 8, 3, 9, 10, 16, 6, 7, 12, 20, 18, 22, 17, 21, 11, 13, 24, 25, 32, 40, 19, 33, 34, 35, 36, 37, 41, 64, 14, 38, 42, 66, 48, 52, 50, 80, 39, 65, 68, 70, 15, 23, 67, 69, 44, 72, 26, 28, 29, 73, 76, 84, 27, 74, 82, 88, 86, 128, 30, 31, 49, 81, 89
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
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
Cf. A109812, A353731 (primes), A353732 (inverse), A354141 (powers of 2), A354142, A353733 (variant).
KEYWORD
nonn,look,base
AUTHOR
Rémy Sigrist, Apr 04 2022
STATUS
approved
a(n) = smallest number missing from A353733 after A353733(n) has been found.
+10
1
1, 2, 3, 3, 3, 3, 3, 7, 7, 7, 7, 7, 7, 11, 11, 11, 11, 11, 11, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 23, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 27, 27, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 31, 43, 43, 43, 43, 43, 43
OFFSET
0,2
LINKS
PROG
(Python)
from itertools import count, islice
def agen(): # generator of terms
A353733lst, A353733set, mink = [0], {0}, 1
for n in count(1):
yield mink; A353733half, k = A353733lst[(n-1)//2], mink
while k in A353733set or k&A353733half: k += 1
A353733lst.append(k); A353733set.add(k)
while mink in A353733set: mink += 1
print(list(islice(agen(), 68))) # Michael S. Branicky, May 18 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, May 18 2022
STATUS
approved

Search completed in 0.005 seconds