OFFSET
1,1
COMMENTS
Terms computed by Claudio Meller.
We set a(n)=0 when n has repeated digits; for example, a(11) = 0, a(22) = 0, a(100) = 0, a(101) = 0, since compact(c) cannot result in such n. Is n=450 the first other number that has no solution?
LINKS
Michel Marcus, Table of n, a(n) for n = 1..449
PROG
(PARI) f(n) = {my(d=digits(n)); fromdigits(vecextract(d, vecsort(vecsort(d, , 9))))}; \\ A137564
isokd(m) = my(d=digits(m)); #d == #Set(d); \\ A010784
a(n) = my(d=digits(n)); if (#Set(d) == #d, my(m=1); while (!isokd(m) || (f(n+m) != n), m++); m); \\ Michel Marcus, Jan 13 2022
(Python)
def has_repeated_digits(n): s = str(n); return len(s) > len(set(s))
def A137564(n):
seen, out, s = set(), "", str(n)
for d in s:
if d not in seen: out += d; seen.add(d)
return int(out)
def a(n):
if n == 0 or has_repeated_digits(n): return 0
m = 1
while has_repeated_digits(m) or A137564(n+m) != n: m += 1
return m
print([a(n) for n in range(1, 61)]) # Michael S. Branicky, Jul 23 2022
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Rodolfo Kurchan, Sep 26 2020
STATUS
approved