OFFSET
1,2
COMMENTS
The sequence was suggested by Wolfdieter Lang and represents a(n) - a(n-1) for the sequence A256379, which alternately adds and subtracts each digit of a particular value in the integers.
LINKS
Anthony Sand, Table of n, a(n) for n = 1..1000
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
EXAMPLE
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.
PROG
(PARI) { nmx=1000; b=10; dig=vector(b); si=0; for(i=1, b, dig[i]=1); n=0; s=0; while(n<nmx, n++; d=digits(n, b); prev=s; for(i=1, #d, s+=d[i]*dig[d[i]+1]; dig[d[i]+1]*=-1; ); print1(s-prev); if(n<nmx, print1(", ")); ); }
CROSSREFS
KEYWORD
sign,base,easy
AUTHOR
Anthony Sand, Apr 11 2015
STATUS
approved
