Skip to content
FiftyCalc Free calculators for all 50 states

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

Sample figures

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.

Terminating Decimal Calculator

Numerator p (whole number): enter a number. Prefilled example: 7.

Denominator q (whole number, not 0, up to 15 digits): enter a number. Prefilled example: 40.

How to use this calculator

Fill in the fields in this order; each step takes you to its field.

  1. Numerator p (whole number): enter a number.
  2. Denominator q (whole number, not 0, up to 15 digits): enter a number.
  3. 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

  1. G={gcd⁡(p,q)if q≠0No result for these inputsotherwise
  2. Qq=|q|G
  3. R=Qq÷gcd⁡(Qq,4,503,599,627,370,496)gcd⁡(Qqgcd⁡(Qq,4,503,599,627,370,496),2,384,185,791,015,625)
  4. Ok={2if q=01if R=10otherwise
Symbols used in the formula
SymbolMeaning
pNumerator p (whole number)
qDenominator q (whole number, not 0, up to 15 digits)
GGreatest common divisor of p and q
QqDenominator in lowest terms
RWhat is left of it after removing every factor 2 and 5
OkTerminating 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 q1
Denominator in lowest terms40
What is left of it after removing every factor 2 and 51
Number of decimal places3
Decimal value p ÷ q0.175
  1. G=gcd⁡(7,40)=1
  2. Qq=|40|1=40
  3. R=40÷gcd⁡(40,4,503,599,627,370,496)gcd⁡(40gcd⁡(40,4,503,599,627,370,496),2,384,185,791,015,625)=1
  4. Ok=1

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.

Questions answered

Related calculators