login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A340125
Numbers whose sum of even digits and sum of odd digits are equal and whose digits are in nondecreasing order.
1
0, 112, 134, 156, 178, 336, 358, 1223, 1245, 1267, 1289, 1447, 1469, 2334, 2356, 2378, 2558, 3445, 3467, 3489, 3669, 4556, 4578, 5667, 5689, 6778, 7889, 11114, 11136, 11158, 11338, 12225, 12247, 12269, 12449, 22233, 22345, 22367, 22389, 22556, 22578, 23447, 23469, 24455
OFFSET
1,2
LINKS
EXAMPLE
1223 is in the sequence as the sum of the odd digits is 1 + 3 = 4 and the sum of the even digits is 2 + 2 = 4 are equal.
MATHEMATICA
seodQ[n_]:=With[{idn=IntegerDigits[n]}, Total[Select[idn, EvenQ]]==Total[Select[idn, OddQ]]&&Min[Differences[idn]]>=0]; Select[Range[0, 25000], seodQ] (* Harvey P. Dale, Dec 30 2024 *)
PROG
(PARI) is(n) = { my(d = digits(n), w = vector(2)); if(d != vecsort(d), return(0)); for(i = 1, #d, w[d[i]%2 + 1] += d[i] ); w[1] == w[2] }
(Python)
def ok(n):
digs = list(map(int, str(n)))
return sorted(digs) == digs and sum(d*(-1)**d for d in digs) == 0
def aupto(lim): return [m for m in range(lim+1) if ok(m)]
print(aupto(24455)) # Michael S. Branicky, Feb 21 2021
CROSSREFS
Intersection of A009994 and A036301.
Sequence in context: A359142 A329719 A157662 * A095615 A361339 A061281
KEYWORD
nonn,base
AUTHOR
David A. Corneth, Feb 21 2021
STATUS
approved