[go: up one dir, main page]

login
A358097
a(n) is the smallest integer m > n such that m and n have no common digit, or -1 when such integer m does not exist.
3
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 22, 20, 30, 20, 20, 20, 20, 20, 20, 20, 31, 30, 30, 40, 30, 30, 30, 30, 30, 30, 41, 40, 40, 40, 50, 40, 40, 40, 40, 40, 51, 50, 50, 50, 50, 60, 50, 50, 50, 50, 61, 60, 60, 60, 60, 60, 70, 60, 60, 60, 71, 70, 70, 70, 70, 70, 70, 80, 70, 70, 81, 80, 80, 80, 80
OFFSET
0,2
COMMENTS
When n is pandigital with or without 0 (A050278, A050289, A171102), m does not exist, so a(n) = -1; see examples for smallest pandigital cases.
LINKS
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
Cf. A030283 (trajectory starting 0).
Cf. A358098 (similar, with largest integer m < n).
Sequence in context: A134817 A067581 A099469 * A039112 A160015 A276392
KEYWORD
nonn,base,easy
AUTHOR
Bernard Schott, Oct 29 2022
STATUS
approved