OFFSET
0,3
COMMENTS
Leading zeros in the binary expansion of n are ignored.
The value a(0) = 1 corresponds to the empty concatenation.
The following sequences f correspond to the numbers of ways of writing the binary expansion of a number as a concatenation of substrings with some specific features:
f f(2^n-1) Features
------- -------- --------
For any such sequence f, the function n -> f(2^n-1) corresponds to a composition of n.
LINKS
FORMULA
a(2^n - 1) = A003242(n) for any n >= 0.
EXAMPLE
For n = 19: the binary expansion of 19, "10011", can be split in 11 ways into nonempty substrings with no two consecutive equal substrings:
- (10011),
- (1001)(1),
- (100)(11),
- (10)(011),
- (10)(01)(1),
- (10)(0)(11),
- (1)(0011),
- (1)(001)(1),
- (1)(00)(11),
- (1)(0)(011),
- (1)(0)(01)(1).
Hence a(19) = 11.
PROG
(PARI) a(n{, pp=0}) = if (n==0, return (1), my (v=0, p=1); while (n, p=(p*2) + (n%2); n\=2; if (p!=pp, v+=a(n, p))); return (v))
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Apr 08 2018
STATUS
approved