OFFSET
1,810
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..100000
EXAMPLE
From Antti Karttunen, Dec 15 2017: (Start)
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:
map(f, [$1..100]); # Robert Israel, Dec 15 2017
MATHEMATICA
a[n_] := Count[Length /@ Split[IntegerDigits[n, 9]], _?EvenQ];
Array[a, 120] (* Jean-François Alcover, Dec 16 2017 *)
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
More terms and secondary offset added by Antti Karttunen, Dec 15 2017
STATUS
approved