cp's OEIS Frontend

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.

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.

Original entry on oeis.org

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

Views

Author

Matt Donahoe, Aug 27 2024

Keywords

Examples

			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.
		

Crossrefs

Programs

  • 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
  • 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
  • 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
    

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