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”).
%I #28 Apr 15 2015 06:47:12
%S 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,
%T 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,
%U 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
%N Cumulative sum for n in base 10 when alternately adding and subtracting each digit of a particular value.
%C 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.
%C 0 <= a(n) <= 45 for all n; a(n) = a(n mod 20) for odd n. - _Danny Rorabaugh_, Mar 31 2015
%H Anthony Sand, <a href="/A256379/b256379.txt">Table of n, a(n) for n = 1..1000</a>
%F a(n) = Sum_{k=1..n} M(k), with M(k) := Sum_{m=1..r(k)} ((-1)^(a(k,m) + 1)*digit(k,m),
%F 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
%t 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 *)
%o (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(", ")); ); }
%Y Cf. A037123, A167232, A256100, A256851 (first differences).
%K nonn,base
%O 1,2
%A _Anthony Sand_, Mar 27 2015