login

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”).

A375776
Bitwise conflict-free sequence: Each number n is placed into the first set k that contains no element x where n AND x > 0: a(n) = k.
1
1, 1, 2, 1, 3, 4, 5, 1, 4, 3, 6, 2, 7, 8, 9, 1, 8, 7, 10, 6, 11, 12, 13, 5, 14, 15, 16, 17, 18, 19, 20, 1, 12, 11, 17, 10, 15, 14, 21, 13, 22, 23, 24, 25, 26, 27, 28, 2, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 1, 19, 18, 25, 16, 23, 22, 36, 10, 30, 29, 32
OFFSET
1,3
LINKS
FORMULA
a(n) = 1 <=> n in { A000079 }. - Andrew Howroyd, Aug 27 2024
a(n) = 2 <=> n in { A164346 }. - Alois P. Heinz, Aug 27 2024
a(n) = A279125(n) + 1. - Rémy Sigrist, Aug 30 2024
EXAMPLE
For n = 1, a(1) = 1 because 1 gets put into the first set.
For n = 2, a(2) = 1 because 2 AND 1 == 0, so 2 can also be put into the first set.
For n = 3, a(3) = 2 because 3 AND 1 == 1, so 3 must be put into a new set.
MAPLE
s:= proc() {} end:
a:= proc(n) option remember; local k; for k
while ormap(x-> Bits[And](x, n)>0, s(k)) do od;
s(k):= {s(k)[], n}; k
end:
seq(a(n), n=1..75); # Alois P. Heinz, Aug 27 2024
PROG
(Python)
def seq(n):
L = [0] + [0] * n
for i in range(1, n + 1):
k = next((k for k in range(1, len(L)) if i & L[k] == 0), None)
L[k] |= i
yield k
(PARI) seq(n)={my(a=vector(n), L=vector(n)); for(n=1, n, for(j=1, oo, if(!bitand(n, L[j]), L[j]=bitor(L[j], n); a[n]=j; break))); a} \\ Andrew Howroyd, Aug 27 2024
CROSSREFS
KEYWORD
nonn,look,base
AUTHOR
Matt Donahoe, Aug 27 2024
STATUS
approved