OFFSET
0,2
COMMENTS
LINKS
Michel Marcus, Table of n, a(n) for n = 0..10000
FORMULA
a(10^n-k) = 10^n when n >= 2 and 1 <= k <= 8.
a(10^n) = 2 * A002275(n+1), when n >= 1.
EXAMPLE
a(10) = 22; a(11) = 20; a(12) = 30.
a(123456789) = -1; a(1234567890) = -1.
MATHEMATICA
a[n_] := Module[{d = Complement[Range[0, 9], IntegerDigits[n]], m = n + 1}, If[d == {} || d == {0}, -1, While[! AllTrue[IntegerDigits[m], MemberQ[d, #] &], m++]; m]]; Array[a, 100, 0] (* Amiram Eldar, Oct 29 2022 *)
PROG
(PARI) isfull(d) = my(dd=setminus([0..9], d)); (dd==[]) || (dd==[0]);
a(n) = my(d=Set(digits(n))); if (isfull(d), -1, my(k=n+1); while (#setintersect(Set(digits(k)), d), k++); k); \\ Michel Marcus, Oct 29 2022
(Python)
from itertools import count, product
def a(n):
s = str(n)
r = sorted(set("1234567890") - set(s))
if len(r) == 0 or r == ["0"]: return -1
for d in count(len(s)):
for p in product(r, repeat=d):
m = int("".join(p))
if m > n: return m
print([a(n) for n in range(75)]) # Michael S. Branicky, Oct 29 2022
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Bernard Schott, Oct 29 2022
STATUS
approved