OFFSET
1,2
COMMENTS
For n = 1..9, the function is encountering each digit for the first time, therefore each is added to the cumulative sum. At n = 9, the sum is 45. At n = 10, the sum is 44, because the digit 1 is encountered for the second time and is therefore subtracted. At n = 11, the sum is again 44, because 1 is added and then subtracted. At n = 12, the sum is 43, because 1 is added and 2, encountered for the second time, is subtracted.
0 <= a(n) <= 45 for all n; a(n) = a(n mod 20) for odd n. - Danny Rorabaugh, Mar 31 2015
LINKS
Anthony Sand, Table of n, a(n) for n = 1..1000
FORMULA
a(n) = Sum_{k=1..n} M(k), with M(k) := Sum_{m=1..r(k)} ((-1)^(a(k,m) + 1)*digit(k,m),
where a(k,m) = A256100(k,m) read as an array with row length r(k) (number of digits of k), and digit(k,m) is the m-th digit of k. - Wolfdieter Lang, Apr 08 2015
MATHEMATICA
f[n_] := Block[{g, r = PadRight[Range@ 9, 10]}, g[x_] := Boole[OddQ /@ DigitCount[x]]; Total[r Boole[OddQ /@ Total[g /@ Range@ n]]]]; Array[f, 120] (* Michael De Vlieger, Mar 29 2015 *)
PROG
(PARI) { nmx=1000; b=10; dig=vector(b); for(i=1, b, dig[i]=1); n=0; s=0; while(n<nmx, n++; d=digits(n, b); for(i=1, #d, s+=d[i]*dig[d[i]+1]; dig[d[i]+1]*=-1; ); print1(s); if(n<nmx, print1(", ")); ); }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Anthony Sand, Mar 27 2015
STATUS
approved