A071650 Difference between sums of odd and even digits of n.
1, -2, 3, -4, 5, -6, 7, -8, 9, 1, 2, -1, 4, -3, 6, -5, 8, -7, 10, -2, -1, -4, 1, -6, 3, -8, 5, -10, 7, 3, 4, 1, 6, -1, 8, -3, 10, -5, 12, -4, -3, -6, -1, -8, 1, -10, 3, -12, 5, 5, 6, 3, 8, 1, 10, -1, 12, -3, 14, -6, -5, -8, -3, -10, -1, -12, 1, -14, 3, 7, 8, 5, 10
Offset: 1
Links
- Michel Marcus, Table of n, a(n) for n = 1..10000
Programs
-
Mathematica
Table[Total[Select[IntegerDigits[n],OddQ]]-Total[Select[ IntegerDigits[ n],EvenQ]],{n,80}] (* Harvey P. Dale, Jul 27 2020 *)
-
PARI
a(n) = {my(d=digits(n), s = 0); for (k=1, #d, if (d[k] % 2, s += d[k], s -= d[k]);); s;} \\ Michel Marcus, Aug 05 2017
-
PARI
A071650(n)=-vecsum(apply(t->(-1)^t*t,digits(n))) \\ M. F. Hasler, Dec 09 2018