OFFSET
1,2
COMMENTS
This is different from |A055017(n)| = |(x1 + x3 + ...) - (x2 + x4 + ...)|, where x1,...,xk are the digits of n. - M. F. Hasler, Nov 09 2019
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
FORMULA
If decimal expansion of n is x1 x2 ... xk then a(n) = |x1-x2-x3- ... -xk|.
EXAMPLE
a(371) = |3-7-1| = 5.
PROG
(Haskell) a040997 n = abs $ a000030 n - a007953 (a217657 n) -- Reinhard Zumkeller, Oct 10 2012
(PARI) apply( A040997(n)={abs(vecsum(n=digits(n))-n[1]*2)}, [1..199]) \\ M. F. Hasler, Nov 09 2019
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
EXTENSIONS
Name edited and incorrect formula deleted by M. F. Hasler, Nov 09 2019
STATUS
approved