Type 1/8 into a calculator and you get 0.125. Type 1/3 and the display fills with threes until it runs out of room. The size of the numbers has nothing to do with it. Whether a fraction ends depends only on the prime factors of its denominator, and the same rule explains why 0.1 + 0.2 comes out as 0.30000000000000004 in most programming languages.
Lowest Terms and Euclid's Algorithm
A fraction is in lowest terms when the numerator and denominator share no factor other than 1. To get there, divide both by their greatest common divisor (GCD). 18 and 12 have a GCD of 6, so 18/12 reduces to 3/2.
Listing factors works for small numbers and becomes hopeless for large ones. The method this calculator uses, along with practically every computer algebra system, is the one in Book VII of Euclid's Elements, written around 300 BC. Replace the larger number with the remainder of dividing it by the smaller, and repeat until the remainder is zero. The last non-zero remainder is the GCD.
For 1071 and 462: 1071 = 2 × 462 + 147, then 462 = 3 × 147 + 21, then 147 = 7 × 21 + 0. The GCD is 21, found in three divisions. Gabriel Lamé proved in 1844 that the number of steps is never more than five times the number of digits in the smaller number, which is why a 15-digit fraction reduces as fast as a 2-digit one.
Why the Least Common Denominator, Not Just Any
To add 3/4 and 5/6, both fractions need the same denominator. Multiplying the two denominators always works: 4 × 6 = 24 gives 18/24 + 20/24 = 38/24, which then has to be reduced to 19/12. The least common denominator, LCM(4, 6) = 12, gives 9/12 + 10/12 = 19/12 directly.
Both routes reach the same answer. What changes is the size of the numbers along the way, and that gap grows fast. Adding 1/12 + 1/18 + 1/30 over the product of the denominators means working in 6,480ths. The least common multiple is 180.
The LCM comes straight from the GCD: LCM(a, b) = a × b ÷ GCD(a, b). When the denominators share no factor, as 4 and 7 don't, the GCD is 1 and the least common denominator is simply their product, 28. When one denominator divides the other, as 4 divides 8, the larger one is already the answer.
Multiplying and dividing skip the common denominator
Multiplication goes straight across: (2 × 3)/(3 × 4) = 6/12 = 1/2. Division means multiplying by the reciprocal, so 3/4 ÷ 3/8 = 3/4 × 8/3 = 24/12 = 2. A common denominator is only needed for adding and subtracting.
Which Fractions End as Decimals
Write the fraction in lowest terms and factor the denominator. If the only primes in it are 2 and 5, the decimal terminates. If any other prime appears, it repeats forever.
The reason is that a terminating decimal is a fraction over a power of ten, and 10 = 2 × 5. 1/8 can be rewritten as 125/1000 because 8 = 2³ divides 1000 = 2³ × 5³. No power of ten is divisible by 3, so 1/3 can never be written over one, and the long division never comes out even.
The number of decimal places is predictable too. It equals the larger of the two exponents. 40 = 2³ × 5, so 1/40 ends after three places at 0.025. 16 = 2⁴, so 1/16 needs four: 0.0625.
The rule only applies after reducing. 3/6 seems to have a 3 in its denominator, but it reduces to 1/2, which is 0.5.
How Long the Repeating Block Is
For a prime p other than 2 and 5, the period of 1/p is the smallest k for which 10^k − 1 is divisible by p.
| Fraction | Decimal | Repeating digits |
|---|---|---|
| 1/3 | 0.333… | 1 |
| 1/11 | 0.0909… | 2 |
| 1/37 | 0.027027… | 3 |
| 1/101 | 0.00990099… | 4 |
| 1/41 | 0.0243902439… | 5 |
| 1/7 | 0.142857142857… | 6 |
| 1/13 | 0.076923076923… | 6 |
| 1/17 | 0.0588235294117647… | 16 |
| 1/19 | 0.052631578947368421… | 18 |
Where the Repeating Block Comes From
Long division can only leave as many different remainders as the denominator minus one. Dividing by 7, every step leaves a remainder from 1 to 6. As soon as a remainder comes back, everything after it repeats, because the division from that point on is identical. That is how the calculator finds the repeat: it records each remainder and stops when one reappears.
So 1/p repeats with a period of at most p − 1 digits, and by Fermat's little theorem the period always divides p − 1 exactly. Primes that reach the maximum, like 7, 17 and 19, are called full reptend primes. For them every multiple uses the same digits, rotated: 1/7 = 0.142857…, 2/7 = 0.285714…, 3/7 = 0.428571….
Gauss worked through these periods at length in Disquisitiones Arithmeticae (1801). A further pattern was published by E. Midy in 1836 and now carries his name: when the period of 1/p is even, its two halves add up to a row of nines. For 1/7, 142 + 857 = 999. For 1/17, 05882352 + 94117647 = 99999999.
Check any fraction
Exact results with every step, plus the decimal with its repeating block marked.
Why 0.1 + 0.2 Is Not 0.3 in Code
The rule holds in every number base, with the base's own prime factors in place of 2 and 5. Most software stores numbers in binary floating point as defined by IEEE 754, where the base is 2. In binary, a fraction terminates only if its denominator is a power of 2.
1/10 has a 5 in its denominator, so in binary it repeats forever as 0.000110011001100… and has to be rounded to fit 53 significant bits. The same happens to 2/10. Add the two rounded values and the error surfaces in the 17th significant digit: 0.1 + 0.2 gives 0.30000000000000004.
This is why accounting software stores money as whole cents or uses a decimal type, and why this calculator takes whole-number numerators and denominators instead of decimals. Integer arithmetic is exact, so 1/10 + 2/10 is 3/10 with nothing lost.
Four Mistakes That Show Up Again and Again
Most wrong answers with fractions come from a handful of habits, and each one has a quick check.
Adding the denominators
1/2 + 1/3 is not 2/5. The answer is 5/6. A fast sanity check: 2/5 is smaller than 1/2, and adding a positive number can't make the total smaller.
Splitting a negative mixed number
−2 1/3 means −(2 + 1/3), which is −7/3. Reading it as −2 + 1/3 gives −5/3, a different number. The minus sign applies to the whole mixed number.
Cancelling across a plus sign
Only factors cancel. 6/12 reduces to 1/2, but in (2 + 4)/(2 + 10) the 2s cannot be crossed out. Work out the sums first, then reduce 6/12.
Reducing only at the end
It isn't wrong, but it makes the numbers grow. 15/28 × 14/45 straight across is 210/1260. Cancelling 15 with 45 and 14 with 28 first gives 1/3 × 1/2 = 1/6 without ever touching a four-digit number.
Frequently Asked Questions
Related Tools
Keep Reading
Percentage Change vs Percentage Points, and Other Costly Confusions
Down 50 percent then up 50 percent leaves you down 25. Why percentages are not symmetric, and how stacked discounts really multiply.
Where Hex Converters Quietly Round Off Your 64-Bit Numbers
FFFFFFFFFFFFFFFF is 18446744073709551615, but a lot of tools say ...552000. The 53-bit significand behind it, and why all ones means minus one.
Length Units: The Inch Is Defined in Metres, and Other Surprises
Every imperial unit has been legally metric since 1959. Where the US survey foot differed until 2023, and the conversion error that lost a Mars orbiter.
Date Arithmetic Is Harder Than It Looks: Leap Years and Feb 29
One month after 31 January has no single right answer. How months create ambiguity, and when a leap-day baby legally turns 18.