OFFSET
0,5
COMMENTS
We set a(0) = 0 by convention.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..8192
FORMULA
EXAMPLE
The first terms, alongside the binary representations of n, n+1 and a(n), are:
n a(n) bin(n) bin(n+1) bin(a(n))
-- ---- ------ -------- ---------
0 0 0 1 0
1 1 1 10 1
2 1 10 11 1
3 1 11 100 1
4 2 100 101 10
5 2 101 110 10
6 3 110 111 11
7 1 111 1000 1
8 4 1000 1001 100
9 2 1001 1010 10
10 5 1010 1011 101
PROG
(PARI) sub(n) = { my (b=binary(n), s=[0]); for (i=1, #b, if (b[i], for (j=i, #b, s=setunion(s, Set(fromdigits(b[i..j], 2)))))); return (s) }
a(n) = my (i=setintersect(sub(n), sub(n+1))); i[#i]
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jan 26 2020
STATUS
approved