|
|
A341005
|
|
Numbers whose sum of even digits and sum of odd digits differ by 4.
|
|
2
|
|
|
4, 13, 22, 31, 40, 103, 116, 125, 130, 138, 147, 152, 161, 169, 174, 183, 196, 202, 215, 220, 233, 251, 301, 310, 318, 323, 332, 345, 354, 367, 376, 381, 389, 398, 400, 417, 435, 453, 471, 512, 521, 534, 543, 556, 565, 578, 587, 611, 619, 637, 655, 673, 691, 714, 736, 741, 758
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
LINKS
|
|
|
MATHEMATICA
|
Select[Range[1000], Abs[Plus @@ Select[(d = IntegerDigits[#]), OddQ] - Plus @@ Select[d, EvenQ]] == 4 &] (* Amiram Eldar, Feb 02 2021 *)
|
|
PROG
|
(Python)
def ok(n):
sums = [0, 0]
for d in str(n): sums[d in "13579"] += int(d)
return abs(sums[0] - sums[1]) == 4
|
|
CROSSREFS
|
Cf. A071650 (difference between sum of even and sum of odd digits).
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|