OFFSET
0,3
LINKS
FORMULA
EXAMPLE
The first terms, alongside the binary representations of n as well as those of the numbers that appear in it, are:
n a(n) bin(n) {bin(s)}
-- ---- ------ ----------------------------
0 0 0 {0}
1 1 1 {1}
2 3 10 {0, 1, 10}
3 4 11 {1, 11}
4 7 100 {0, 1, 10, 100}
5 11 101 {0, 1, 10, 11, 101}
6 12 110 {0, 1, 10, 11, 110}
7 11 111 {1, 11, 111}
8 15 1000 {0, 1, 10, 100, 1000}
9 24 1001 {0, 1, 10, 11, 100, 101, 1001}
10 31 1010 {0, 1, 10, 11, 100, 101, 110, 1010}
PROG
(PARI) a(n, base=2) = { my (b=digits(n, base), s=[0]); for (k=1, #b, s = setunion(s, apply(o -> base*o+b[k], s))); vecsum(s) }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Nov 30 2019
STATUS
approved