Write out \dfrac{1}{7} as a decimal and something strange happens. You get
Six digits, then the same six digits again, forever. Not five, not seven — six, exactly. Change the fraction to \tfrac{1}{11} and the repeat length is 2. Change it to \tfrac{1}{13} and it jumps to 6 again. Change it to \tfrac{1}{17} and the repeat length is 16. Where are these numbers coming from?
The pattern is not magic. It drops out of a small observation about long division — and once you see it, you can predict the repeat length of any fraction without ever doing the division.
The remainders are doing the work
When you long-divide 1 by 7, you are repeatedly computing remainders. Watch the remainders carefully.
- 1 \div 7: quotient 0, remainder 1.
- Bring down a zero: 10 \div 7 = 1, remainder 3.
- Bring down a zero: 30 \div 7 = 4, remainder 2.
- Bring down a zero: 20 \div 7 = 2, remainder 6.
- Bring down a zero: 60 \div 7 = 8, remainder 4.
- Bring down a zero: 40 \div 7 = 5, remainder 5.
- Bring down a zero: 50 \div 7 = 7, remainder 1.
At step 7, the remainder is 1 again — the same remainder we started with. The moment the remainder repeats, the entire sequence of quotient digits is forced to repeat too, because from here onward we are asking the same division questions in the same order. The quotient digits we collected — 1, 4, 2, 8, 5, 7 — form the repeating block.
Why the cycle must close
At every step of long division by 7, the remainder is a number between 0 and 6 — there are only 7 possible values. Exclude 0 (which would terminate the division), and you are left with 6 possible non-zero remainders: \{1, 2, 3, 4, 5, 6\}.
You can produce at most 6 new remainders before you are forced to repeat one. That is a pigeonhole argument — six pigeonholes, seven pigeons, two must share. In practice, for \tfrac{1}{7}, all six non-zero values appear exactly once, and then the cycle closes on itself.
Why: once a remainder repeats, the same division sub-problem is being set up again, so the same quotient digit comes out, and the next remainder is determined, and so on. The decimal digits from that point onward are an exact copy of the digits from the first occurrence. Repetition of one remainder forces repetition of all remainders downstream.
The general rule
Here is the result that pops out.
The repeat length of \tfrac{1}{q} is the smallest integer k \geq 1 such that 10^k \equiv 1 \pmod{q}.
This looks technical, but it is saying exactly what we saw above. The remainders of long division are the successive values of 10, 100, 1000, \ldots taken mod q. When one of those hits 1, the division cycle returns to its start. The smallest such exponent is the length of the cycle.
Let us check a few:
| q | smallest k with 10^k \equiv 1 \pmod{q} | repeat length | decimal |
|---|---|---|---|
| 3 | 10^1 = 10 \equiv 1 | 1 | 0.\overline{3} |
| 7 | 10^6 = 1000000 \equiv 1 | 6 | 0.\overline{142857} |
| 9 | 10^1 = 10 \equiv 1 | 1 | 0.\overline{1} |
| 11 | 10^2 = 100 \equiv 1 | 2 | 0.\overline{09} |
| 13 | 10^6 \equiv 1 | 6 | 0.\overline{076923} |
| 17 | 10^{16} \equiv 1 | 16 | 0.\overline{0588235294117647} |
| 19 | 10^{18} \equiv 1 | 18 | 0.\overline{052631578947368421} |
For q = 7, the powers of 10 mod 7 are 10 \equiv 3, 10^2 \equiv 2, 10^3 \equiv 6, 10^4 \equiv 4, 10^5 \equiv 5, 10^6 \equiv 1. Six steps to get back to 1. Six-digit repeat.
For q = 11, the powers of 10 mod 11 are 10 \equiv 10, 10^2 \equiv 1. Two steps. Two-digit repeat.
Why the length divides q - 1
A deeper fact: for prime q (not 2 or 5), the repeat length always divides q - 1. That is why the repeat lengths for 7, 11, 13, 17, 19 are 6, 2, 6, 16, 18 — each a divisor of q - 1.
This is a consequence of Fermat's little theorem: for any prime q and integer a coprime to q, a^{q-1} \equiv 1 \pmod{q}. Applied to a = 10, this says 10^{q-1} \equiv 1 \pmod{q}, which means the repeat length (the smallest exponent that makes 10^k \equiv 1) divides q - 1. The possible repeat lengths for \tfrac{1}{7} are therefore the divisors of 6: 1, 2, 3, 6. We observed it to be 6 — the maximum.
When the repeat length equals q - 1, the prime q is called a full reptend prime. The primes 7, 17, 19, 23, 29, 47, 59, 61, \ldots are full reptend; 11, 13, 31, 37, 41, 43, \ldots are not. For a full reptend prime, every non-zero remainder from 1 to q - 1 appears exactly once in the cycle — which is why \tfrac{1}{7} visits all of \{1, 2, 3, 4, 5, 6\} before returning.
What this tells you about \tfrac{1}{7} specifically
The six-digit block of \tfrac{1}{7} is 142857. Because 7 is a full reptend prime, the decimals of \tfrac{2}{7}, \tfrac{3}{7}, \tfrac{4}{7}, \tfrac{5}{7}, \tfrac{6}{7} are all cyclic shifts of the same six digits:
- \tfrac{1}{7} = 0.\overline{142857}
- \tfrac{2}{7} = 0.\overline{285714}
- \tfrac{3}{7} = 0.\overline{428571}
- \tfrac{4}{7} = 0.\overline{571428}
- \tfrac{5}{7} = 0.\overline{714285}
- \tfrac{6}{7} = 0.\overline{857142}
Same six digits every time — only the starting point rotates. This is a mathematical beauty that falls out of the remainder cycle: multiplying by k just skips you k steps around the cycle.
And one more: 142857 \times 7 = 999999. Multiply any full-reptend repeat block by its denominator and you get a string of 9s. This is equivalent to \tfrac{1}{q} \times q = 1, spelled out in the decimal world.
The rule for composite denominators
For a denominator that is not prime — say \tfrac{1}{12} or \tfrac{1}{21} — strip out any factors of 2 and 5 first (those cause a non-repeating pre-period, not the repeat itself), then the repeat length of the remaining part is determined by the same rule: smallest k with 10^k \equiv 1 mod (the remaining factor).
- \tfrac{1}{12} = \tfrac{1}{4 \times 3}. Factor out 4 = 2^2; the "3" part gives repeat length 1. Combined with a pre-period of 2 (from the 4): \tfrac{1}{12} = 0.08\overline{3}.
- \tfrac{1}{21} = \tfrac{1}{3 \times 7}. No factors of 2 or 5. Repeat length is the smallest k with 10^k \equiv 1 \pmod{21} — which turns out to be 6. So \tfrac{1}{21} = 0.\overline{047619}.
The factors of 2 and 5 cleanly "move" a copy of the decimal point to create a finite prefix, and the rest of the denominator decides the repeat length. That is why "terminate vs. repeat" depends on 2s and 5s, but "how long the repeat is" depends on the other primes. (See how to tell termination from the denominator for the terminate/repeat half of the story.)
What to remember
- The repeat length of \tfrac{1}{q} is the length of the remainder cycle when you long-divide — the number of steps before the same remainder reappears.
- That length equals the smallest k with 10^k \equiv 1 \pmod{q}.
- For prime q (not 2 or 5), the repeat length always divides q - 1. So \tfrac{1}{7} has length 1, 2, 3, or 6 — and happens to be 6.
- When the repeat length equals q - 1, the prime is "full reptend," and the decimals of \tfrac{k}{q} for k = 1, 2, \ldots, q-1 are all cyclic shifts of the same string.
- Factors of 2 and 5 in the denominator create a non-repeating prefix but don't change the repeat length itself.
So the six-digit block of \tfrac{1}{7} is not a coincidence. It is the shortest cycle of remainders when you repeatedly multiply by 10 in the world modulo 7 — and that cycle is forced to close within six steps because there are only six non-zero remainders available. The decimal expansion is the shadow cast by a piece of clean modular arithmetic.
Related: Fractions and Decimals · How to Know If a Fraction Terminates or Repeats — Without Doing the Division · Long Division Reveals the Repeating Block — Watch the Loop Appear · Repeating-Decimal Patterns: 1/7, 1/11, 1/13 Side by Side