A256851 First-order differences for the cumulative sum of the digits of the integers when alternately adding and subtracting each digit of a particular value.
1, 2, 3, 4, 5, 6, 7, 8, 9, -1, 0, -1, -4, -3, -6, -5, -8, -7, -10, 2, -1, 0, 5, 2, 7, 4, 9, 6, 11, -3, 2, -5, 0, -1, -8, -3, -10, -5, -12, 4, -3, 6, -1, 0, 9, 2, 11, 4, 13, -5, 4, -7, 2, -9, 0, -1, -12, -3, -14, 6, -5, 8, -3, 10, -1, 0, 13, 2, 15, -7, 6, -9, 4, -11, 2, -13, 0, -1, -16, 8, -7, 10, -5, 12, -3, 14, -1, 0, 17, -9, 8, -11, 6, -13, 4, -15
Offset: 1
Examples
a(0) = 0, therefore a(1) - a(0) = 1 - 0 = 1. For n = 1..9, the function is encountering each digit for the first time, therefore a(9) = 45. For n = 10, the function encounters the digit 1 for the second time and subtracts it. Therefore a(10) = 44 and a(10) - a(9) = -1.
Links
- Anthony Sand, Table of n, a(n) for n = 1..1000
Programs
-
PARI
{ nmx=1000; b=10; dig=vector(b); si=0; for(i=1,b,dig[i]=1); n=0; s=0; while(n
Formula
a(n) = Sum_{m=1..r(n)} (-1)^(a(n,m) + 1)*digit(n,m), where a(n,m) = A256100(n,m) read as an array with row length r(n) (number of digits of n), and digit(n,m) is the m-th digit of n (see the formula for A256379). - Wolfdieter Lang, Apr 15 2015
Comments