# Decimal expansions of rational numbers.

One can use modular arithmetic to find the decimal expansion of a rational number. (see 1: https://i.stack.imgur.com/kw4Gk.png).

Using the same method I have run into a couple of problems.

1. $$x = \frac{1}{6}$$

In this case $$m =1$$ and $$n=6$$. Then the remainders are $$1, 10 \equiv 4, 40 \equiv 4, ...$$

so therefore $$10^2 \cdot 1 \equiv 10^1 \cdot 1 \pmod{6}$$. Now $$10^2-10^1 = 90 = 6 \cdot 15$$ and so $$\left(10^2 -10^1\right)x = 15$$, but doing long division $$x = 0.1\overline{6}$$ and not $$x = 0.1\overline{15}$$. I am not really understanding the final step to determine $$x$$.

1. $$x = \frac{1}{37}$$.

In this case $$m =1$$ and $$n =37$$. Then the remainders are $$1, 10 \equiv 10, 100 \equiv 26, 260 \equiv 1.$$ So $$10^3 \cdot 1 \equiv 1 \pmod{37}$$. Now $$10^3 -1 = 999 = 27 \cdot 37$$. Therefore so $$(10^3-1)x =27$$, and by method above $$x = 0.\overline{27}$$, but doing long division $$x = 0.\overline{027}$$.

Clearly I am doing something wrong, the method should work for both of these cases. However I am not sure what it is?

For $$\dfrac {1}{6} \dots$$

\begin {align} 1\operatorname {mod} 6 \equiv 1 \\ 10\operatorname {mod} 6 \equiv 4 \\ 40\operatorname {mod} 6 \equiv 4 \\ \end {align}

$$4$$ is the repeating number, so we say $$\color \red {10^2 - 4} = 96 = 6 \cdot 16$$, and $$(10^2 - 4)x = (16) \rightarrow x = \dfrac {16}{10^2-4} \rightarrow \dfrac {16}{96} \rightarrow \bbox [2px, border: 2px solid black]{x = .1\overline{6}}$$.

For $$\dfrac {1}{37} \dots$$

\begin {align} 1\operatorname {mod} 37 \equiv 1 \\ 10\operatorname {mod} 37 \equiv 10 \\ 100\operatorname {mod} 37 \equiv 26 \\ 260\operatorname {mod} 37 \equiv 1 \\ \end {align}

$$1$$ is the repeating number, so we say $$10^3 - 1 = 999 = 37 \cdot 27$$, and $$\color \red {(10^3 - 1)}x = 27 \rightarrow x = \dfrac {27}{10^3-1} \rightarrow x = \dfrac {27}{999} \rightarrow \bbox [2px, border: 2px solid black] {x = \overline{.027}}$$.

It's equivalent to what we do when we write out the fraction in long division, because in each case we're multiplying by 10 when we reduce the modulo, then stop when we've found a repeating number. The highest power of $$10$$ in which a remainder repeates is where we find out the equivalent fraction.

• But then what about the example. 1 is subtracted, not 3.
– xAly
Nov 3, 2018 at 19:01
• Divide $3$ from $3 \cdot 10^6 \equiv 3 \operatorname {mod} 7$ and use Fermat's Little Theorem ($a^{p-1} = 1 \operatorname {mod} p$). If you tried to subtract $3$ from $10^6$ you would have two primes that are not divisible by $7$. Nov 3, 2018 at 20:20