A341005 Numbers whose sum of even digits and sum of odd digits differ by 4.
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
Offset: 1
Links
- Carole Dubois, Table of n, a(n) for n = 1..5001
Crossrefs
Programs
-
Mathematica
Select[Range[1000], Abs[Plus @@ Select[(d = IntegerDigits[#]), OddQ] - Plus @@ Select[d, EvenQ]] == 4 &] (* Amiram Eldar, Feb 02 2021 *)
-
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 print(list(filter(ok, range(759)))) # Michael S. Branicky, Apr 13 2021