OFFSET
0,4
COMMENTS
We set a(0) = 0 by convention.
a(7479) = 29 ("11101" in binary) is the first term that does not belong to A057890.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..8192
FORMULA
EXAMPLE
The first terms, alongside the binary representations of n and of a(n), are:
n a(n) bin(n) bin(a(n))
-- ---- ------ ---------
0 0 0 0
1 1 1 1
2 1 10 1
3 3 11 11
4 1 100 1
5 5 101 101
6 3 110 11
7 7 111 111
8 1 1000 1
9 9 1001 1001
10 5 1010 101
11 5 1011 101
12 3 1100 11
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(fromdigits(Vecrev(binary(n)), 2)))); i[#i]
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jan 26 2020
STATUS
approved