OFFSET
1,2
LINKS
David A. Corneth, Table of n, a(n) for n = 1..10001
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.
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
KEYWORD
nonn,base
AUTHOR
David A. Corneth, Feb 21 2021
STATUS
approved