login
a(n) is the smallest positive integer m with no repeated digits such that A137564(n + m) = n, or a(n) = 0 if no m exists.
2

%I #34 Jul 24 2022 02:04:23

%S 10,20,30,40,50,60,70,80,90,90,0,109,120,127,136,145,154,163,172,180,

%T 190,0,209,218,230,236,245,254,263,270,280,290,0,309,318,327,340,345,

%U 354,360,370,380,390,0,409,418,427,436,450,450,460,470,480,490,0,509,518,527,536,540

%N a(n) is the smallest positive integer m with no repeated digits such that A137564(n + m) = n, or a(n) = 0 if no m exists.

%C Terms computed by _Claudio Meller_.

%C 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?

%H Michel Marcus, <a href="/A337857/b337857.txt">Table of n, a(n) for n = 1..449</a>

%o (PARI) f(n) = {my(d=digits(n)); fromdigits(vecextract(d, vecsort(vecsort(d, , 9))))}; \\ A137564

%o isokd(m) = my(d=digits(m)); #d == #Set(d); \\ A010784

%o 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

%o (Python)

%o def has_repeated_digits(n): s = str(n); return len(s) > len(set(s))

%o def A137564(n):

%o seen, out, s = set(), "", str(n)

%o for d in s:

%o if d not in seen: out += d; seen.add(d)

%o return int(out)

%o def a(n):

%o if n == 0 or has_repeated_digits(n): return 0

%o m = 1

%o while has_repeated_digits(m) or A137564(n+m) != n: m += 1

%o return m

%o print([a(n) for n in range(1, 61)]) # _Michael S. Branicky_, Jul 23 2022

%Y Cf. A010784, A137564.

%K base,nonn

%O 1,1

%A _Rodolfo Kurchan_, Sep 26 2020