Try `1 ÷ 4` in your head. You get a clean 0.25 — done. Now try `1 ÷ 3`. You get 0.333… — the threes go on forever. Why?
The answer is short: it depends only on the denominator of the fraction in lowest terms.
The rule
A fraction `n/d` in lowest terms is:
terminating — if the denominator `d` only has 2 and 5 as prime factors (or none);
recurring — if `d` has any other prime factor (3, 7, 11, 13, …).
Examples — terminating
fraction
decimal
denominator
1/2
0.5
2
1/4
0.25
4 = 2·2
1/5
0.2
5
1/8
0.125
8 = 2³
3/20
0.15
20 = 2²·5
Examples — recurring
fraction
decimal
denominator
1/3
0.333…
3
1/6
0.1666…
6 = 2·3
1/7
0.142857142857…
7
1/9
0.111…
9 = 3²
5/11
0.4545…
11
In some cases (1/6, 1/12, …) the recurrence does not start immediately — you get a couple of fixed digits first and then the repeat. That is still a recurring decimal.
Why it works
Our base-10 system has base 10 = 2 × 5. To convert `n/d` neatly into a decimal, you need to express the denominator as a power of ten. This is only possible when `d` has only 2s and 5s in its factorisation.
Rewriting as a power of 10: `1/8 = 125/1000` (we multiplied by 125 since 8 × 125 = 1000). That gives 0.125.
If the denominator also has a 3 or 7 or another "odd" prime factor, you can never push it into a power of 10 — so the expansion necessarily repeats.
Recognition tips
First reduce the fraction to lowest terms.
Look at the denominator: if you can break it down to 2s and 5s only, it terminates.