login
A198376
Largest n-digit number whose product of digits is n or 0 if no such number exists.
2
1, 21, 311, 4111, 51111, 611111, 7111111, 81111111, 911111111, 5211111111, 0, 621111111111, 0, 72111111111111, 531111111111111, 8211111111111111, 0, 921111111111111111, 0, 54111111111111111111, 731111111111111111111, 0, 0, 831111111111111111111111
OFFSET
1,2
LINKS
FORMULA
a(A068191(n)) = 0 for n >=1.
a(n) <> 0 iff n in { A002473 }. - Michael S. Branicky, Jan 21 2021
EXAMPLE
113, 131, and 311 are the 3-digit numbers whose product of digits is 3; 311 is the largest.
MATHEMATICA
Table[If[FactorInteger[n][[-1, 1]] > 9, 0, i = (10^n - 1)/9; While[i < 10^n && Times @@ (d = IntegerDigits[i]) != n, i++]; If[i == 10^n, 0, FromDigits[Reverse[d]]]], {n, 30}] (* T. D. Noe, Oct 24 2011 *)
PROG
(Python)
def A198376(n):
ncopy, p, an = n, 1, ""
for d in range(9, 1, -1):
while ncopy%d == 0: ncopy//=d; p *= d; an += str(d)
if p == n and len(an) <= n: return int(an+'1'*(n-len(an)))
return 0
print([A198376(n) for n in range(1, 25)]) # Michael S. Branicky, Jan 21 2021
CROSSREFS
Cf. A198375 (smallest), A002473, A068191.
Sequence in context: A125478 A018054 A021484 * A306428 A317201 A281254
KEYWORD
nonn,base
AUTHOR
Jaroslav Krizek, Oct 23 2011
STATUS
approved