OFFSET
0,3
LINKS
FORMULA
EXAMPLE
. ----+-------+---------------+------------
. 0 | 0 | 0 | 0
. 1 | 1 | 1 | 1
. 2 | 3 | 11 | 2
. 3 | 2 | 10 | 1
. 4 | 5 | 101 | 2
. 5 | 4 | 100 | 1
. 6 | 6 | 110 | 2
. 7 | 7 | 111 | 3
. 8 | 9 | 1001 | 2
. 9 | 8 | 1000 | 1
. 10 | 10 | 1010 | 2
. 11 | 11 | 1011 | 3
. 12 | 12 | 1100 | 2
. 13 | 13 | 1101 | 3
. 14 | 15 | 1111 | 4
. 15 | 14 | 1110 | 3
. 16 | 17 | 10001 | 2 .
MATHEMATICA
a[0] = 0; a[n_] := a[n] = Module[{bw = DigitCount[a[n - 1], 2, 1], k = 1}, While[!FreeQ[Array[a, n - 1], k] || Abs[DigitCount[k, 2, 1] - bw] != 1, k++]; k]; Array[a, 100, 0] (* Amiram Eldar, Jul 18 2023 *)
PROG
(Haskell)
import Data.List (delete)
a266089 n = a266089_list !! n
a266089_list = 0 : f 0 (zip [1..] $ tail a000120_list) where
f x zws = g zws where
g (yw@(y, w) : yws) | abs (x - w) /= 1 = g yws
| otherwise = y : f w (delete yw zws)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Reinhard Zumkeller, Dec 22 2015
STATUS
approved