login
A390761
a(n) is the smallest positive integer k which has the same set of digits as n, and k is divisible by each nonzero digit of n, or -1 if no such number exists.
1
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 12, 1113, 144, 15, 1116, 1771, 1888, 1111111119, 20, 12, 2, 2232, 24, -1, 2226, 2772, 288, 2222222292, 30, 1113, 2232, 3, 3444, 3555, 36, 37737, 3888, 3339, 40, 144, 24, 3444, 4, -1, 4464, 44744, 48, 4444444944, 50, 15, -1, 3555
OFFSET
1,2
COMMENTS
a(n) = -1 if and only if the digits of n does not contain 0 but contains 5 and one or more nonzero even number.
Conjecture: a(709) = 707777779779 is the largest a(n) for all n.
Conjecture is true, via exhaustive testing of all subsets of decimal digits. Indeed, the cardinality of the range is 783 (including -1; see a-file for values). - Michael S. Branicky, Nov 19 2025
FORMULA
a(n) = a(A137564(n)). - Michael S. Branicky, Nov 19 2025
EXAMPLE
a(13) = a(31) = 1113 because 1113 is the least integer composed with 1's and 3's that is divisible by both 1 and 3.
MATHEMATICA
a[n_] := (d = Union@IntegerDigits[n]; lcm = LCM @@ Select[d, Positive];
If[d[[1]] > 0 && Divisible[lcm, 10], Return[-1]];
l = Length[d]; Do[f = Join @@ Table[d, j];
v = FromDigits /@
Union@Select[Permutations[f, {j}], #[[1]] > 0 && Union@# == d &];
For[k = 1, k <= Length@v, k++,
If[Mod[v[[k]], lcm] == 0, Return[v[[k]]]]], {j, l, 20}]);
Table[a[n], {n, 60}]
PROG
(Python)
import math
from itertools import product
from functools import reduce
def lcm(a, b):
return abs(a * b) // math.gcd(a, b) if a and b else 0
def a(n):
d = [int(x) for x in sorted(set(str(n)))]
non_zero = [x for x in d if x > 0]
lc=reduce(lcm, non_zero)
if not non_zero or (d[0] > 0 and lc % 10 == 0):
return -1
for j in range(len(d), 21):
for perm in product(d, repeat=j):
if perm[0] > 0 and set(perm) == set(d):
num = int(''.join(map(str, perm)))
if num % lc == 0:
return num
print( [a(n) for n in range(1, 61)])
CROSSREFS
KEYWORD
sign,base
AUTHOR
Zhining Yang, Nov 17 2025
STATUS
approved