Subscribe!
My latest posts can be
found here:
Previous blog posts:
Additionally, some earlier writings:

Repeating decimal expansions  2019/05/09
Recently online I saw someone talking about the decimal expansion
of pi, and they said:

In normal base 10 numbering ... 3.14159265358979...
The three dots at the end signal that this series
goes on for ever  it is infinite.
A second claim is made that the series is everchanging
and never repeats. I describe that as a claim because
I can't see how it can be proved



We had a bit of a discussion, and I thought it would be worth putting
down a few thoughts, aimed at people who are intrigued, but who have
absolutely no mathematical background (or at least, none of which they
are confident). I might not succeed, probably won't, but here are some
basic concepts to help people get a start at seeing how and why these
things work.
In this post I'm going to show that we have the following:
 There are two kinds of numbers:
 those for which the decimal expansion eventually repeats, and
 those for which the decimal expansion does not repeat.
Well, that doesn't seem like it requires much proof. Either something
does or does not eventually repeat.
Next, I'm going to show this:
 There are numbers that:
 can be expressed as the ratio of two "whole numbers"
 (by which I mean numbers such as 3, 2, 1, 0, 1, 2, 3, etc.),
and there are numbers that
 cannot be expressed as the ratio of two whole numbers.
It's pretty clear that there are numbers that can be expressed as a
ratio, I can simply exhibit some: $\frac{2}{3}$ is one, $\frac{7}{4}$
is another, for example. What is perhaps less clear is that there are
numbers (whatever we mean by that) that cannot be written as the
ratio of two whole numbers. We'll get to that.
The third, and most marvellous thing is this:
 The numbers whose decimal expansions eventually repeat are
exactly those numbers that can be written as a ratio of
two whole numbers.
This will be a long post because I'm going to take it gently. I hope
it will be an easy read, but don't be seduced into thinking the ideas
are easy. There are some very deep things going on here, so every now
and again you may have to back up and reread something from earlier.
Let's start by evaluating some fractions, some ratios, and make some
observations.
Firstly:
 $\frac{1}{8}$ evaluates to 0.125
 $\frac{5}{2}$ evaluates to 2.5
These don't look like they go on forever, I know, but for the sake of
consistency I want to include the infinite trailing zeroes that are
implicitly there. So actually these are:
 $\frac{1}{8}$ evaluates to 0.1250000...
 $\frac{5}{2}$ evaluates to 2.5000000...
We are also fairly familiar with these:
 $\frac{1}{3}$ evaluates to 0.3333333...
 $\frac{7}{6}$ evaluates to 1.1666666...
We're pretty happy that these (a) go on forever, and (b) repeat. In
the second case the repeat is "eventual"  it doesn't start repeating
immediately after the decimal point. Other examples of that might be:
 $\frac{17}{120}$ evaluates to 0.14166666666...
 $\frac{51}{88}$ evaluates to 0.57954545454...
So far all these ratios have been repeating, possibly eventually, and
possibly trivially, but certainly repeating.
So questions that naturally arise:
 Is this always true?
 How do you know?
It's always true.
A few comments:
 The technical term for what we're calling "whole numbers" is
"integer";
 The integers include the negative numbers;
 We're assuming that we're not dividing by zero.

The claim is that every time we have a ratio, a fraction, a division
of one whole number by another, then the result is always a repeating
decimal (possibly trivially). How can we prove that?
One way to think about division is to ask: "How many bunches of 7 can
we make from 178 things?" We can just subtract off 7 repeatedly and
see how many times we could do that (25, with 3 left over), but we can
do it more efficiently by a technique called "chunking". We remove a
chunk of 7s all at once, and keep track of those lumps.
This will feel needlessly complicated, but stick with it for a
moment  perhaps skim and come back later. 
We start by working in 10s.
How many tens of 7 can we remove from 178?
We can remove 2 lots of 10s of 7.
In other words, we can remove 20 lots of 7.
That's 140, which we remove from 178, leaving a remainder (so far) of 38.
Now let's work in 1s.
How many 1s of 7 can we remove from 38?
We can remove 5 lots of 1s of 7.
In other words, we can remove 5 lots of 7.
That's 35, which we remove from 38, leaving a remainder (so far) of 3.
Now let's work in tenths.
Our remainder is 3, which is 30 tenths.
How many tenths of 7 can we remove from 30 tenths?
We can remove 4 lots of tenths of 7.
In other words, we can remove 4 lots of tenths of 7 from
30 tenths, leaving 2 tenths.
The much maligned algorithm that everyone loves to hate
on  long division  is exactly this process done efficiently
and in tabular form. 
Then we can work in hundredths, and so on. At each stage we have a
remainder, and we can continue. If that remainder is ever zero then
the process stops, but otherwise it goes on forever.
So at every stage we take away some sevens and are left with a
remainder, and the stream of digits in the result is, at each stage,
determined by that remainder.
But the remainders must always be less than seven, otherwise we could
have removed more of them. As a result, eventually the remainder will
be the same as one we've seen before, and at that point the process
goes into a cycle.
So when we do a division, unless it "goes exactly" (which has the
remainder of zero somewhere) the digits we get must eventually repeat,
and will then do so forever.
Thus we have shown that the decimal expansion of a fraction always
repeats.
But wait  there's more!
Note: There is some very deep and very cool number theory
in the obvious question "What will the period length be?" I'm most
definitely not going to go into that here. Maybe another time. 
When dividing by 7 there are only 6 possible remainders, so the length
of the repeat must be no more than 6. You can see that by doing some
examples with 13, 14, 15, etc. The length of the repeat will always
be less than the number you're dividing by:
 $\frac{3}{13}$ gives a repeat length of 6;
 $\frac{3}{11}$ gives a repeat length of 2;
 $\frac{3}{7}$ gives a repeat length of 6;
 $\frac{1}{6}$ gives a repeat length of 1;
So every fraction, when expressed as a decimal, is always a repeating
decimal, although possibly trivially (being all zeroes) and possibly
only after an initial period of nonrepeating digits.
What about the converse?
So if every fraction is a repeating decimal, is every repeating decimal
necessarily expressible as an exact fraction?
Yes.
Let's see how to do that. Here we'll demonstrate the process with a
specific example, but the process will work with any number.
Take some repeating decimal:
This starts with 8.238 and then we have "63" repeated endlessly. To
start, we multiply up by a power of ten that is enough to have only
the repeats after the decimal point. In this case there are three
initial digits after the decimal point, so we'll multiply up by 1000.
At the end, whatever answer we get, we'll divide out by that 1000 to
put things back the way they were.
So now we have this:
OK, subtract off the integer part, which is 8238, to leave us with:
That's a bit bigger than 0.63 which is $\frac{63}{100}$, so we want to
divide 63 by something a little smaller than 100. Let's try 99:
 $\frac{63}{99}$ gives us what we want: 0.636363636363...
I am well aware that this is a bit "rabbit from a hat".
This process really does work, and it's not hard to prove, but
it will take a post at least as long as this to do it carefully.
You don't need to bother with these final manipulations,
as we already have our target number as the result of additions,
multiplications, and divisions, so the result must be expressible
as a fraction.
But feel free to check and follow along for completeness.

And this works in general. Look at the length of the repeat, then
put the repeating bit over that many 9s. Our repeat is of length 2,
so we put 63 over 99.
So our fraction is $8238+\frac{63}{99}$ divided by 1000. The final
form is:
 $\frac{8238\times{99}+63}{99000}$ or $\frac{815625}{99000}$
That can then be reduced to lowest terms, giving $\frac{725}{88}$.
This process works for every repeating decimal, although the proof
will have to wait for another day. However, assuming it does work,
and it certainly seems to with the examples to hand, we have shown
that every repeating decimal can be written as a fraction, a ratio
of whole numbers.
Taking stock ...
So we have shown that every fraction can be expressed as a repeating
decimal, and every repeating decimal can be expressed as a fraction.
That means that a number that never repeats is not a fraction, it's
not a ratio.
Thus we have:
 A number that does not eventually repeat is irrational.
 An irrational number when expressed as a decimal never repeats.
Still to do (in some order):
 A new(ish) proof that $\sqrt{2}$ is irrational, and hence never repeats;
 A proof that the "divide by 99" trick always works;
 A proof that $e$ is irrational, and hence never repeats;
 A proof that $\pi$ is irrational, and hence never repeats;
 The difference between "irrational" and "transcendental".
And possibly more.
Send us a comment ...
