|
|
A044940
|
|
Number of runs of even length in base-9 representation of n.
|
|
5
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,810
|
|
LINKS
|
|
|
EXAMPLE
|
For n = 810 = 729 + 81 = 9^3 + 9^2 thus in base 9 written as "1100", we count two runs, both of length 2, thus both even, so a(810) = 2.
For n = 32805 = 5*(9^4), thus in base 9 "50000", there is one run of even length, so a(32805) = 1.
For n = 65630 = 1*(9^5) + 1*(9^4) + 0*(9^3) + 0*(9^2) + 2*(9^1) + 2*(9^0) thus written as "110022" in base 9, there are three runs, all of length 2, thus all even, so a(65630) = 3.
(End)
|
|
MAPLE
|
f:= proc(n) local i, j, t, Q, d;
Q:= convert(n, base, 9);
d:= nops(Q);
i:= 1: t:= 0:
while i < d do
for j from i+1 to d while Q[j] = Q[i] do od:
if (j-i)::even then t:= t+1 fi;
i:= j;
od;
t
end proc:
|
|
MATHEMATICA
|
a[n_] := Count[Length /@ Split[IntegerDigits[n, 9]], _?EvenQ];
|
|
PROG
|
(PARI) A044940(n) = { my(rl=1, d, prev_d = -1, s=0); while(n>0, d = (n%9); n = ((n-d)/9); if(d==prev_d, rl++, s += (1-(rl%2)); prev_d = d; rl = 1)); (s + (1-(rl%2))); }; \\ Antti Karttunen, Dec 15 2017
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|