[go: up one dir, main page]

login
Largest n-digit number divisible by the product of its decimal digits.
1

%I #23 May 11 2020 02:27:19

%S 9,36,816,9612,93744,973728,9939915,99221112,997711344,9993393711,

%T 99934212672,999641938176,9999121936392,99996414731136,

%U 999994123418112,9999982411646976,99999318116613312,999991631331122112,9999944111773994112,99999911232931433472,999999832211912282112

%N Largest n-digit number divisible by the product of its decimal digits.

%C The smallest such numbers are given by repunits A000042 or A002275.

%H Max Alekseyev, <a href="/A246757/b246757.txt">Table of n, a(n) for n = 1..30</a>

%o (PARI) { A246757(n) = my(m,d,p,q); m=n\2; forstep(k=10^m-1,(10^m-1)/9,-1, d=digits(k); q=prod(i=1,#d,d[i]); if(q==0,next); forstep(s=(((k+1)*10^(n-m))\q)*q,k*10^(n-m),-q, d=digits(s); p=prod(i=1,#d,d[i]); if(p==0 || s%p,next); return(s) )) }

%o (Python)

%o from operator import mul

%o from functools import reduce

%o def A246757(n):

%o for i in range(10**n-1,int('1'*n)-1,-1):

%o pd = reduce(mul,(int(d) for d in str(i)))

%o if pd and not i % pd:

%o return i # _Chai Wah Wu_, Sep 08 2014

%Y Subsequence of A007602.

%K nonn,base

%O 1,1

%A _Max Alekseyev_, Sep 02 2014