A071648 Sum of even decimal digits of n.
0, 2, 0, 4, 0, 6, 0, 8, 0, 0, 0, 2, 0, 4, 0, 6, 0, 8, 0, 2, 2, 4, 2, 6, 2, 8, 2, 10, 2, 0, 0, 2, 0, 4, 0, 6, 0, 8, 0, 4, 4, 6, 4, 8, 4, 10, 4, 12, 4, 0, 0, 2, 0, 4, 0, 6, 0, 8, 0, 6, 6, 8, 6, 10, 6, 12, 6, 14, 6, 0, 0, 2, 0, 4, 0, 6, 0, 8, 0, 8, 8, 10, 8, 12, 8, 14, 8, 16, 8, 0, 0, 2
Offset: 1
Links
- Michael De Vlieger, Table of n, a(n) for n = 1..10000
Programs
-
Mathematica
Array[Total@ Select[IntegerDigits@ #, EvenQ] &, 101] (* Michael De Vlieger, Dec 09 2018 *)
-
PARI
a(n)=my(d=digits(n)); sum(i=1,#d,if(d[i]%2,,d[i])) \\ Charles R Greathouse IV, Apr 04 2014
-
PARI
A071648(n)=vecsum(select(d->!bittest(d,0),digits(n))) \\ Nearly twice as fast. - M. F. Hasler, Dec 09 2018