You are making great progress in Rational Numbers as Decimals — this is the third of four lessons in the course, so you are three-quarters of the way through. In the first two lessons, you used long division to convert fractions into terminating and repeating decimals, and you learned how to express repeating results with bar notation. That hands-on work gave you a solid feel for how these two decimal types behave.
In this lesson, we take a shortcut. Instead of carrying out the full division every time, you will learn a quick test that tells you whether a fraction's decimal will terminate or repeat just by looking at the fraction itself. By the end, you will be able to make that prediction in seconds.
A Natural Question
Think about the fractions you have already converted. Some, like 41​, divided out neatly to 0.25. Others, like 31​, produced a remainder that cycled forever. It would save a lot of work if you could tell which type of decimal a fraction will produce before picking up a pencil.
The good news is that there is a reliable rule, and it depends entirely on the denominator of the fraction. To uncover it, let's line up some examples and look for a pattern.
Spotting a Pattern in Denominators
Consider these fractions whose decimals terminate:
Fraction
Decimal
Denominator
Prime factorization
21​
0.5
2
2
41​
0.25
4
2×2
51​
0.2
5
5
81​
0.125
8
2×2×2
201​
0.05
20
2×2×5
251​
0.04
25
5×5
Every denominator in this list is built from the primes 2 and 5 only — no other prime factors appear. Now compare that with a few repeating examples:
Fraction
Decimal
Denominator
Prime factorization
31​
0.3
3
3
61​
0.16
6
2×3
71​
0.142857
7
7
111​
0.09
11
11
Each of these denominators contains at least one prime factor other than 2 or 5. That contrast is not a coincidence — it points directly to a rule you can use every time.
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal
Here is the rule we can draw from the pattern above:
A fraction in lowest terms produces a terminating decimal if and only if the prime factorization of its denominator contains no primes other than 2 and 5. If any other prime factor appears, the decimal repeats.
Why do 2 and 5 get this special role? Because our number system is base 10, and 10=2×5. A terminating decimal is really a fraction whose denominator is a power of 10. For example:
0.25=10025​=10225​
Since 10n=2n×5n, any denominator built solely from 2s and 5s can be scaled up to a power of 10 by multiplying by the right combination of 2s or 5s. A denominator that carries a factor like 3 or 7 can never reach a power of 10, so the division never comes out even and the decimal repeats.
Let's practice the prediction step by step with three fractions already in lowest terms.
Example 1:403​
Factor the denominator: 40=2×2×2×5. Only 2s and 5s appear, so the decimal terminates. (If you check: 3÷40=0.075.)
Example 2:125​
Factor the denominator: 12=2×2×3. The factor 3 is present, so the decimal repeats. (Check: 5÷12=0.416.)
Example 3:167​
Factor the denominator: 16=2×2×2×2. Only 2s, so the decimal terminates. (7÷16=0.4375.)
Notice that we never needed to perform any long division to make these predictions. One quick look at the denominator's prime factors was enough.
The rule above applies to fractions in lowest terms. If a fraction has not been simplified, the denominator may contain misleading factors that cancel out when the fraction is reduced.
Consider 126​. The denominator 12=2×2×3 contains a 3, which would suggest a repeating decimal. But 126​ simplifies to 21​, and 2 is built from only 2s. The decimal is 0.5 — it terminates.
Here is another example: 153​. The denominator 15=3×5 has a factor of 3. Yet 153​ reduces to 51​, and 5 consists of only 5s. The result is 0.2, a terminating decimal. The lesson is simple: always reduce first, then check the denominator.
The following flowchart summarizes the complete decision process:
You deal with terminating decimals every time you handle money. Common subdivisions of a dollar, like quarters (41​) and nickels (201​), work because their denominators are built only from 2s and 5s. This ensures the division stops, resulting in exact decimal amounts like $0.25 and $0.05.
Even if a fraction doesn't result in a whole number of cents, the rule still holds. For example, 81​ of a dollar is $0.125 (12 and a half cents). Because 8=2×2×2, the decimal terminates, even though it goes past the hundredths place.
Now try splitting a dollar into thirds. The fraction 31​ has a denominator of 3, a prime that is neither 2 nor 5. That is why one-third of a dollar is $0.333... — an amount that can never be written as an exact decimal. Our currency uses subdivisions like halves, quarters, and tenths because their denominators ensure the math always comes to a clean stop.
In this lesson, you learned a quick and powerful prediction rule: once a fraction is in lowest terms, factor the denominator. If the only prime factors are 2 and 5, the decimal terminates; if any other prime appears, it repeats. This connection traces back to the fact that our base-10 system is built on 10=2×5, and you also saw why reducing a fraction before applying the test is essential.
Now it is your turn to put this rule to work. The practice exercises ahead will ask you to predict decimal types, connect predictions to prime factorizations, handle fractions that need reducing first, and explain the rule in a familiar money setting — so get ready to show what you have learned!