login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A256379
Cumulative sum for n in base 10 when alternately adding and subtracting each digit of a particular value.
4
1, 3, 6, 10, 15, 21, 28, 36, 45, 44, 44, 43, 39, 36, 30, 25, 17, 10, 0, 2, 1, 1, 6, 8, 15, 19, 28, 34, 45, 42, 44, 39, 39, 38, 30, 27, 17, 12, 0, 4, 1, 7, 6, 6, 15, 17, 28, 32, 45, 40, 44, 37, 39, 30, 30, 29, 17, 14, 0, 6, 1, 9, 6, 16, 15, 15, 28, 30, 45, 38, 44, 35, 39, 28, 30, 17, 17, 16, 0, 8, 1, 11, 6, 18, 15, 29, 28, 28, 45, 36, 44, 33, 39, 26, 30
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
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
Cf. A037123, A167232, A256100, A256851 (first differences).
Sequence in context: A338334 A107082 A267238 * A187845 A130488 A061076
KEYWORD
nonn,base
AUTHOR
Anthony Sand, Mar 27 2015
STATUS
approved