## Rational numbers and decimal expansions

As you may remember from school, rational numbers have a terminating or eventually repeating (periodic) decimal expansion, whereas irrational numbers don’t. So, for example, 0.123123123123…, with 123 repeating forever, is rational (in fact, it is equal to 41/333), whereas something like 0.123456789101112131415…, which will never repeat, is irrational.

But do you know why this is true? (Despite what your teachers may have told you, the most important question in mathematics is not how, it is why!) Today I will show why every rational number has a terminating or eventually repeating decimal expansion, and in a future post I will show why every repeating or terminating decimal expansion represents a rational number. From these two pieces of information, of course, we can also deduce that every decimal expansion which doesn’t terminate or repeat must represent an irrational number, and vice versa.

First, what is a decimal expansion? By convention, we use place notation to give each digit a value based on a negative power of ten. In particular,

$\displaystyle 0.d_1d_2d_3d_4\dots = \sum_{i=1}^\infty 10^{-i} d_i$

(Here’s an explanation of sigma notation if you don’t know what the $\Sigma$ means.) For example, recalling that $x^{-a} = 1/x^a$,

$\displaystyle 0.1837\dots = \frac{1}{10} + \frac{8}{100} + \frac{3}{1000} + \frac{7}{10000} + \dots$

Now, how can we convert a rational number, represented as a fraction $p/q$, into a decimal representation? The answer, of course, is to use long division to divide p by q, extending p with zeros after the decimal point as necessary.

Consider performing the division $p/q$. At each step in the division, we are left with a remainder. This remainder, of course, will always be a value between 0 and (q-1), inclusive (if the remainder were larger, it would mean that the quotient we wrote on top was too small). If the remainder is ever zero, then we are done: the decimal representation terminates. If we never get zero as a remainder, the fact that there are only a finite number of possible remainders means that at some point, we must get a remainder that we already got before. But this means that the quotient will now repeat: since we are only bringing down zeros from the dividend, the remainder exactly determines the next digit in the quotient, which determines the next remainder, and so on.

As an example, consider finding the decimal expansion of the rational number 3/7:

It should be clear from the example that after reaching a remainder of 3 for the second time that the quotient will start repeating: 3/7 = 0.428571428571428571…

Therefore, the decimal representation of any rational number will either terminate, or eventually become periodic. (As a bonus challenge, can you figure out how to tell the difference between rational numbers whose decimal expansion terminates, and those whose expansion repeats?) Note that we also know something else: since there are only (q-1) possible non-zero remainders when dividing by q, the repeating portion of the decimal expansion of a rational number with a denominator of q can be at most (q-1) digits long. It could be shorter, but it can’t be any longer. You can also look at this in reverse; for example, if you see a periodic decimal whose repeating portion is ten digits long, you know that the rational number it represents must have a denominator of at least 11.

One more thing to note is that a “terminating” decimal can also be thought of as being followed by an infinite sequence of zeros. So in this sense, even “terminating” decimals are actually periodic.

Next time, I’ll show why the converse is also true: any terminating or repeating decimal represents a rational number. Maybe you can try to figure this out for yourself in the meantime!

This entry was posted in infinity, iteration, number theory, pattern and tagged , , . Bookmark the permalink.

### 9 Responses to Rational numbers and decimal expansions

1. I’ve been fascinated at how any multiple of 1/7 that’s not an integer repeats the same digits in decimal expression, only starting at different points in the sequence:

1/7 = .142857…
2/7 = .285714…
3/7 = .428571…
4/7 = .571428…
5/7 = .714285…
6/7 = .857142…

2. Brent says:

Yup! Do you see why, now? Also, it turns out that there’s nothing particularly special about 7: try experimenting with other denominators, such as, say, 17. I hope to write about this in more detail in a future post.

3. Not really. I mean, why doesn’t the same hold true for, say, 11?

4. Brent says:

Well, instead of answering you I think I’ll just write about this in my next post. =)

5. David says:

What is the exact decimal equivalent of 3922632451/729 ?
I know it MUST either terminate or repeat, but I cannot find a calculator that will give me enough decimal places to determine the exact decimal equivalent.

6. Brent says:

Hi David,

I can imagine you would have trouble finding a calculator with enough precision! In general the repeating period could be up to 728 digits long — although it turns out to be only 81 digits:

3922632451/729 = 5380840.[124828532235939643347050754458161865569272976680384087791495198902606310013717421]

I computed this using a little computer program that I wrote previously (it’s not hard in principle — just do long division, keep track of the remainders along the way, and stop when you see a remainder you’ve seen before). But in general you might want to check out sagenb.org — it lets you use the powerful open-source Sage mathematics package via a web interface! I don’t know the exact Sage commands you would use but I’m absolutely certain that it can compute arbitrary-precision decimals.

7. JM says:

I find this all very interesting! To answer your question about whether a fraction’s decimal expansion will repeat or terminate, a fraction will terminate if and only if the prime factorization of the denominator is made up entirely of 2′s and 5′s. This is unsurprising, because 2 X 5 = 10.