|
|
A044931
|
|
a(n) = so-se, where so(se)=sum of odd(even) base 9 run lengths of n.
|
|
4
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, -1, 3, 3, 3, 3, 3, 3, 3, 3, -1, 3, -1, -1, -1, -1, -1, -1, -1, 3, 3
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,9
|
|
LINKS
|
|
|
EXAMPLE
|
For n = 82 = 1*(9^2) + 0*(9^1) + 1*(9^0), thus written as "101" in base 9, there are three odd runs (each of length 1) and no even runs, so a(82) = 3*1 = 3.
For n = 7383, "11113" in base 9, there is an even run of length 4 and an odd run of length 1, thus a(7383) = 1-4 = -3.
(End)
|
|
MATHEMATICA
|
Array[Total[Length /@ #1] - Total[Length /@ Complement[#2, #1]] & @@ {Select[#, OddQ@ Length@ # &], #} &@ Split@ IntegerDigits[#, 9] &, 100] (* Michael De Vlieger, Dec 16 2017 *)
|
|
PROG
|
(PARI) A044931(n) = { my(rl=0, d, prev_d = -1, s=0); while(n>0, d = (n%9); n = ((n-d)/9); if(d==prev_d, rl++, s += ((-1)^rl)*rl; prev_d = d; rl = 1)); -(s + ((-1)^rl)*rl); }; \\ Antti Karttunen, Dec 16 2017
|
|
CROSSREFS
|
|
|
KEYWORD
|
sign,base
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|