OFFSET
1,3
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..16384
Wikipedia, Bitwise operation
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
AUTHOR
Matt Donahoe, Aug 27 2024
STATUS
approved