Find all $n$ such that $m = an$ or $m =\dfrac{n}{a}$

50 Views Asked by At

$a$ is the 1st digit (from the left) of a $3$-digit number $n$. We get the number $m$ by removing a from $n$ and putting it on the right of the unit-digit. For example, the number $123$ becomes $231$.
Find all $n$ such that $m = an$ or $m =\dfrac{n}{a}$

My Work
Let, $b$ be the last two digits.
So, $n = 100a +b$ and $m = 10b +a$
Then, $10b+a = 100a^2 + ab$, or, $10b + a = \dfrac{100a+b}{a}$

The answer will be the number of solutions to this equation. But I don't know how to solve this equation. Any hint will be helpful.

2

There are 2 best solutions below

0
On BEST ANSWER

There's probably an elegant proof using divisibility, but in the mean time here's a brute-force solution.

We can re-arrange those equations to give $b$ in terms of $a$, and then just plug the values of $[1, 9]$ into $a$.

$$\begin{align} 10b + a & = 100a^2 + ab\\ 10b - ab & = 100a^2 - a\\ (10 - a)b & = (100a - 1)a\\ b & = \frac{(100a - 1)a}{10 - a}\\ \end{align}$$

and

$$\begin{align} 10ab + a^2 & = 100a+b\\ 10ab - b & = 100a - a^2\\ (10a - 1)b & = (100 - a)a\\ b & = \frac{(100 - a)a}{10a - 1}\\ \end{align}$$

Here's a short Python program that evaluates those two equations for $b$ given $a \in \{1,2,3,4,5,6,7,8,9\}$

from __future__ import print_function, division
for a in range(1, 10):
    print(a, (100*a - 1) * a / (10 - a), (100 - a) * a / (10*a - 1))

output

1 11.0 11.0
2 49.75 10.3157894737
3 128.142857143 10.0344827586
4 266.0 9.84615384615
5 499.0 9.69387755102
6 898.5 9.5593220339
7 1631.0 9.4347826087
8 3196.0 9.3164556962
9 8091.0 9.20224719101

Hence $a=1, \, b=11 \implies n = m = 111$ is the only solution.

Note that the first equation is monotonically increasing, so if we were doing this by hand we can stop at $a=3$ since for larger $a$ values $b$ will have 3 digits. Similarly, the second equation is monotonically decreasing, so we can stop at $a=4$ since $b$ will only have 1 digit.

2
On

$a$ takes values in $\{1,2,3,4,5,6,7,8,9\}$. Why not try them all?