|
|
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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
LINKS
|
|
|
FORMULA
|
|
|
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)
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
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|