# What is the least number of digits in $n$?

A positive integer $n$ is multiplied by $7$. The resulting product contains just one digit repeated several times, and that digit is not $7$. What is the least number of digits in $n$?

I can only think of solving this question by brute force. Is there a better way?

You can assume by minimality of $n$ that the digit in $7n$ is 1. And 111111 is divisible by 7, so $n=15873$ and the number of digits is 5.

• Why couldn't it be some other number besides $111111$? – Puzzled417 Dec 14 '15 at 4:59
• @Puzzled417 If $222222$ were a multiple of seven, so would $111111$. It's a theorem that if a prime number $p$ is a factor of $ab$, it's either a factor of $a$ or of $b$ (or both). Here, $p$ is $7$, $a$ is $2$, and $b$ is $111111$. $7$ isn't a factor of $2$, so… (Similarly for the other digits.) – Akiva Weinberger Dec 14 '15 at 5:09
• Well the other answers tell why but.. 1001 is 143*7. So if 1111 is divisible by 7 iff 7|110 iff 7|11 which it doesn't. 7|111 iff 7|111-21=90 iff 7|9. and 7 doesn't divide 11. – fleablood Dec 14 '15 at 5:13
• @Avarind Other than brute force how did you know 7|11111? – fleablood Dec 14 '15 at 5:17
• @fleabood, the simplest way is to keep adding ones till the remainder is zero; using Fermat's little theorem in this case doesn't make the calculation -six divisions - any shorter. – Aravind Dec 14 '15 at 8:29

We know that $7n = \underbrace{dd\ldots dd}_{k \ \text{digits}}$. Hence, $7n \cdot \dfrac{9}{d} = \underbrace{99\ldots 99}_{k \ \text{digits}} = 10^k-1$.

Since $d$ is not $7$, you know that $7n \cdot \dfrac{9}{d} = 10^k-1$ must be divisible by $7$.

Can you determine the smallest positive integer $k$ such that $10^k-1$ is divisible by $7$? Once you do this, coming up with a value for $d$ and $n$ will be easy.

Once you check that the smallest such $k$ is $6$, then you have $7n = dddddd = d \cdot 111111$. To minimize $n$, pick $d = 1$, which gives $n = 15873$.

Let assume that $7\times n = aa\dots a = a\times \underbrace{11\dots 1}_{k \mbox{ times}} = a \times \frac{10^k-1}{9}$.

Because $a \neq 7$, so we must find $k$ such that $10^k-1$ is divided by 7. By Fermat's little theorem, we have $10^6-1$ is divided by 7. Som the minimum of k is less than 6. So, we have the least number of $n$ is 5 (111111/7=15873).