A natural number $N$ is said to be nice if we obtain a divisor of $N$ by erasing one of its digits. A positive integer $X$ is said to be magical if:
- $X$ has distinct digits.
- $X$ is nice.
- The divisor obtained in the above case is magical.
Moreover all one digit numbers are magical. Find the largest magical number.
Let me add some example so that the problem becomes clear.
The number 65 is nice: Deleting 6 gives 5 and 5|65.
The number 625 is magical: 5|25 and 25|625.
Let $n=10^{k+1}b+10^kd+a$ with $a,b,d,k\in\Bbb N$ satisfying
Let $m=10^kb+a$ which is the number obtained from $n$ by erasing the $k$-th digit $d$ and assume $m\mid n$, so that $n$ is a nice number.
Proof. We have $k=0$ and $b\mid d$, hence $n$ has two digits so that $n<100$.
Proof. Let \begin{align} &u=\frac{10^k}{\gcd(a,10^k)}& &v=\frac a{\gcd(a,10^k)} \end{align} so that $1<v<u$ and $\gcd(u,v)=1$. We have \begin{align} \frac nm =\frac{10^{k+1}b+10^kd+a}{10^kb+a} =1+10^k\frac{9b+d}{10^kb+a} =1+u\frac{9b+d}{ub+v} \end{align} and since $\gcd(u,ub+v)=1$, we have $$(ub+v)\mid(9b+d)\tag{1}$$
From $ub+v\leq 9b+d$ we get $$u\leq 9+\frac{d-v}b\leq 17\tag{2}$$ hence the only possible values for $u$ are $2,4,5,8,10,16$.
If we let $q=\frac{9b+d}{ub+v}\in\Bbb N$, then we get $$b=\frac{qv-d}{9-qu}<9\tag{3}$$ For if $q <9/u $, then $9-qu\geq 1$ hence $$b\leq 9v/u-d<9$$ while if $q>9/u$, then $qu-9\geq 1$ hence $$b <d-qv <d\leq 9$$
Consequently, the number of digits of $n $ is $k+1$ which is determined by $u $, hence largest nice number $n$ of this form is obtained for $u=16$. In that case we have $q=1$ for otherwise $qu-9\geq 23$ hence the contradiction $$b\leq\frac {d-qv}{23}<\frac 9 {23}<1$$ Then $b=\frac{d-v}7$ from which $d=8$ and $v=1$, giving the nice number $n=180625$.
Let $n$ be the largest magical number not divisible by $10$ and assume $n>180625$. Then $b=0$, $a\neq 0$ and $d\neq 0$ which implies $a\mid 10^kd$ with $k\geq 5$. Since $n$ doesn't contains repeated digits, it has at most $10$ digits, we have $k\leq 9$ and $a\geq 10^{k-2}$. Thus $10^3\leq a<10^9$ and $a|10^9d$ which reduces the possibility for $a$ to be one of the $28$ numbers satisfying: \begin{align} &2^{10}|a|2^{12}& &2^9\cdot 3|a|2^{10}\cdot 3^2& &2^8\cdot 7|a|2^9\cdot 7\\ &5^5|a|5^9& &5^4\cdot 3|a|5^9\cdot 3^2& &5^4\cdot 7|a|5^9\cdot 7 \end{align}
Note that $2^h\mid a$ implies $k\geq h-3$ and $a\geq 10^{h-5}$: this shows that $a$ cannot satisfy any of the conditions in the first line.
If $5\mid a$, then $a\equiv 5\pmod{10}$, hence $d\neq 5$. Thus $5^h\mid a$ implies $k\geq h$ and $a\geq 10^{h-2}$ which excludes some cases from the second line. Moreover, $5^3\cdot 7\equiv 5^2\cdot 7\equiv 75\pmod{100}$ which implies $5\cdot 7\nmid a$.
A direct computation on the few remaining cases, shows that $a=5^5$ with $d=9$ and $k=5$ is the largest solution giving $n=903125$.