A040997 Absolute value of first digit of n minus sum of other digits of n.
1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Offset: 1
Examples
a(371) = |3-7-1| = 5.
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
Programs
-
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
Formula
If decimal expansion of n is x1 x2 ... xk then a(n) = |x1-x2-x3- ... -xk|.
Extensions
Name edited and incorrect formula deleted by M. F. Hasler, Nov 09 2019
Comments