# What is the largest prime number in the denominator of a fraction that creates a decimal that repeats every 4 digits?

I was studying a Target question for Math League competitions, and after a few hours of pondering, I finally came up with the following method of solving the mentioned problem:

For any decimal, it is obvious that to move 4 digits to the left of the decimal point, you multiply by $10^4$. Given in the above question that those 4 digits repeat endlessly, the integer part of the fraction is equal to the following: $$\frac{10^4}{x} - \frac{1}{x}$$ The above follows from the fact that the sequence after the decimal point is the same fraction no matter how many cycles of the digit repetitions you move to the left of the decimal point since it repeats an infinite amount of cycles.

The above expression simplifies to the following: $$\frac{9999}{x}$$ As I mentioned above, for x to be a solution to the problem, $\frac{9999}{x}$ must be an integer. To find a prime that satisfies the condition that it must divide into $9999$ with no remainder, we can simply take the prime factorization of 9999 which is: $$3^2*11*101$$ Then to satisfy the "largest prime number" condition, we must pick $101$ as the solution.

I looked in the key and found that my solution was right, but I feel that I didn't really prove that $101$ was the largest prime or that my algorithm works for all problems of the same class. Therefore, I am asking here for a generalized form that is perhaps more reliable than my method, assuming that there is one.

• It seems you've proven "if $x$ is a solution then $x$ is a factor of $9999$," when you want "if $x$ is a factor of $9999$ then $x$ is a solution." As it happens, they both turn out to be true. Jan 14, 2016 at 0:49

Your idea is basically right, but the explanation is not altogether clear to me. We could do it this way. Consider $$\frac pq=0\mathord\cdot abcdabcdabcd\cdots\ ,$$ where $p$ and $q$ have no common factor. Then $$9999p=[abcd]q\ ,$$ so $q$ is a factor of $9999=3^2\times11\times101$, and the largest possible prime factor of $q$ is $101$.
At this point we might realise that the question is a bit ambiguous: are we only required to show that $q$ cannot have a prime factor greater than $101$? If so, we are finished. Or must we show also that $q$ actually does have $101$ as a factor? In the latter case we note that if $101$ is not a factor of $q$ then it must be a factor of $[abcd]$; which means that $[abcd]$ actually has the form $[abab]$; which means that the decimal repeats every $2$ digits; which could be interpreted as contrary to what is given.
• Wrong. $1/101 = 0.0099009900\ldots$, $2/101 = 0.019801980\ldots$. Jan 14, 2016 at 1:00
• @vonbrand What exactly is wrong? Are you saying that $101$ is not a factor of the denominators of your fractions? Jan 14, 2016 at 1:03
• They don't have repeat $[abab]$ as you state. Jan 14, 2016 at 1:06
• I don't see how this is wrong. His last statement is about when 101 is not a divisor of $q$, so that is also correct.
• Can you clarify the $9999p=[abcd]q$ part for me? I'm a high school student. Jan 14, 2016 at 1:07