OFFSET
1,4
LINKS
Gheorghe Coserea, Table of n, a(n) for n = 1..10000
EXAMPLE
92 in binary is 1011100. There is a run of one 1, followed by a run of one 0, then a run of three 1's, then finally a run of two 0's. The run lengths are therefore (1,1,3,2). The values of these run lengths that each only occur once are (3,2). Since there are 2 values that occur once, then a(92) = 2.
MATHEMATICA
Table[Count[Tally[Length/@Split[IntegerDigits[n, 2]]], _?(#[[2]]==1&)], {n, 120}] (* Harvey P. Dale, May 11 2017 *)
PROG
(PARI)
binruns(n) = {
if (n == 0, return([1, 0]));
my(bag = List(), v=0);
while(n != 0,
v = valuation(n, 2); listput(bag, v); n >>= v; n++;
v = valuation(n, 2); listput(bag, v); n >>= v; n--);
return(Vec(bag));
};
a(n) = {
my(v = binruns(n), hist = vector(1+logint(n+1, 2)));
for (i = 1, #v, if (v[i] != 0, hist[v[i]]++));
#select(k->(k==1), hist)
};
vector(105, i, a(i)) \\ Gheorghe Coserea, Sep 24 2015
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Leroy Quet, Sep 17 2009
EXTENSIONS
Extended by Ray Chandler, Mar 13 2010
STATUS
approved