Terminating Decimal Calculator
Test cases replayed : 6 of 6 match · Methodology · No outside source listed
Enter a fraction p/q with whole numbers to see whether its decimal expansion ends or repeats forever.
Result
Terminating decimal?
Greatest common divisor of p and q
- Denominator in lowest terms
- What is left of it after removing every factor 2 and 5
- Number of decimal places
- Decimal value p ÷ q
Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.
This browser did not allow copying. The sentence is in the box below, already selected: copy it with your keyboard or the menu.
How to use this calculator
Fill in the fields in this order; each step takes you to its field.
- Numerator p (whole number): enter a number.
- Denominator q (whole number, not 0, up to 15 digits): enter a number.
- Read the result: Terminating decimal?; the panel also shows Greatest common divisor of p and q, Denominator in lowest terms, What is left of it after removing every factor 2 and 5, Number of decimal places and Decimal value p ÷ q.
How this calculator works
A fraction in lowest terms has a terminating decimal exactly when its denominator has no prime factor other than 2 and 5, the prime factors of 10. Otherwise its decimal repeats forever, like 1/3 = 0.333…
The calculator first reduces p/q with the greatest common divisor, then strips the factors 2 (by dividing out gcd(q, 2⁵²)) and 5 (gcd with 5²²). If 1 is left, the decimal terminates.
If the reduced denominator is 2ᵃ × 5ᵇ, the decimal has exactly max(a, b) digits after the point: 7/40, with 40 = 2³ × 5, has three, 0.175.
The formula
| Symbol | Meaning |
|---|---|
| Numerator p (whole number) | |
| Denominator q (whole number, not 0, up to 15 digits) | |
| Greatest common divisor of p and q | |
| Denominator in lowest terms | |
| What is left of it after removing every factor 2 and 5 | |
| Terminating decimal? | |
gcd(a, b, …) | the greatest common divisor of the values. |
Worked example
| Numerator p (whole number) | 7 |
|---|---|
| Denominator q (whole number, not 0, up to 15 digits) | 40 |
| Greatest common divisor of p and q | 1 |
|---|---|
| Denominator in lowest terms | 40 |
| What is left of it after removing every factor 2 and 5 | 1 |
| Number of decimal places | 3 |
| Decimal value p ÷ q | 0.175 |
Terminating decimal? Yes: the decimal terminates
Each step uses the unrounded value of the step before it; figures on this page are rounded for display.
Frequently asked questions
Is 7/40 a terminating decimal?
Yes. 40 = 2³ × 5, so 7/40 = 0.175, with three decimal places.
Why does 7/12 repeat?
12 = 2² × 3, and the factor 3 cannot be cancelled, so 7/12 = 0.58333… repeats.
Does 3/6 terminate?
Yes. It reduces to 1/2 = 0.5: always reduce the fraction before looking at the denominator.