|
|
A165414
|
|
a(n) = number of run-lengths that each occur only once in the binary representation of n.
|
|
2
|
|
|
1, 0, 1, 2, 0, 2, 1, 2, 1, 0, 1, 0, 1, 2, 1, 2, 1, 1, 1, 1, 0, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 2, 1, 1, 3, 0, 1, 0, 3, 1, 1, 0, 1, 0, 1, 1, 1, 2, 3, 0, 0, 0, 1, 0, 3, 0, 3, 1, 3, 2, 1, 2, 1, 2, 1, 1, 3, 2, 1, 2, 1, 2, 0, 1, 0, 1, 0, 2, 3, 1, 1, 1, 0, 1, 0, 1, 1, 2, 0, 1, 0, 2, 1, 1, 1, 2, 3, 2, 1, 1, 0, 1, 1, 2, 0
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,4
|
|
LINKS
|
|
|
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)
};
|
|
CROSSREFS
|
|
|
KEYWORD
|
base,nonn
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|