A353709 a(0)=0, a(1)=1; thereafter a(n) = smallest nonnegative integer not among the earlier terms of the sequence such that a(n) and a(n-2) have no common 1-bits in their binary representations and also a(n) and a(n-1) have no common 1-bits in their binary representations.
0, 1, 2, 4, 8, 3, 16, 12, 32, 17, 6, 40, 64, 5, 10, 48, 65, 14, 128, 33, 18, 68, 9, 34, 20, 72, 35, 132, 24, 66, 36, 25, 130, 96, 13, 144, 98, 256, 21, 42, 192, 257, 22, 104, 129, 258, 28, 97, 384, 26, 37, 320, 136, 7, 80, 160, 11, 84, 288, 131, 76, 272, 161, 70, 264, 49, 134, 328, 512, 19, 44, 448, 513, 30, 224, 768, 15, 112, 640, 259, 52, 200, 514, 53
Offset: 0
Links
- Michael De Vlieger, Table of n, a(n) for n = 0..16384
- Walter Trump, Table of n, a(n) for n = 0..10^6
- Walter Trump, Log-log plot of first 2^24 terms
Crossrefs
Programs
-
Maple
read(transforms) : # ANDnos def'd here A353709 := proc(n) option remember; local c, i, known ; if n <= 2 then n; else for c from 1 do known := false ; for i from 1 to n-1 do if procname(i) = c then known := true; break ; end if; end do: if not known and ANDnos(c, procname(n-2)) = 0 and ANDnos(c, procname(n-1)) = 0 then return c; end if; end do: end if; end proc: # Following R. J. Mathar's program for A109812. [seq(A353709(n), n=0..256)] ; # second Maple program: b:= proc() false end: t:= 2: a:= proc(n) option remember; global t; local k; if n<2 then n else for k from t while b(k) or Bits[And](k, a(n-2))>0 or Bits[And](k, a(n-1))>0 do od; b(k):=true; while b(t) do t:=t+1 od; k fi end: seq(a(n), n=0..100); # Alois P. Heinz, May 06 2022
-
Mathematica
nn = 83; c[] = -1; a[0] = c[0] = 0; a[1] = c[1] = 1; u = 2; Do[k = u; While[Nand[c[k] == -1, BitAnd[a[n - 1], k] == 0, BitAnd[a[n - 2], k] == 0], k++]; Set[{a[n], c[k]}, {k, n}]; If[k == u, While[c[u] > -1, u++]], {n, 2, nn}]; Array[a, nn+1, 0] (* _Michael De Vlieger, May 06 2022 *)
-
Python
from itertools import count, islice def A353709_gen(): # generator of terms s, a, b, c, ab = {0,1}, 0, 1, 2, 1 yield from (0,1) while True: for n in count(c): if not (n & ab or n in s): yield n a, b = b, n ab = a|b s.add(n) while c in s: c += 1 break A353709_list = list(islice(A353709_gen(),20)) # Chai Wah Wu, May 07 2022
Comments