Associated Topics || Dr. Math Home || Search Dr. Math

### Repeating Decimals

```
Date: 04/28/99 at 07:39:22
From: Grabowski
Subject: Long numbers

Hi,

I have been interested in working with fractions, and I would like to
find patterns. When I divide one number by another, I sometimes get a
simple decimal tail, like with 1/8 = 0.125, where the number finishes
or turns into an endless line of zeros. Other times it repeats (as
with 1/3). Then there are some more interesting repeaters, where a
group of digitrs keeps repeating (eg. 1/7 =  0.142857...) I am
interested in finding longer repeating groups in these number tails,
but my calculator doesn't let me see more than a few digits. What can
I do to have divisions like 1/13, and be able to read more than
0.076923076, where I can't tell if the 076923 is really a repeating
group?

I want to try to see what fractions have longer tail repeats, (I know
that pi is infinite), but I have to have a better type of calculator
to work these out because ordinary long division has no joy in it when
going to such a length. Does such a calculator exist? Also, I want to
try to divide terms of the Fibonacci Series and other interesting
sequences (prime numbers?) to see what the repeating situation is with
them.

P. Grabowski
```

```
Date: 04/28/99 at 13:28:26
From: Doctor Rob
Subject: Re: Long numbers

Thanks for writing to Ask Dr. Math!

You have started on an odyssey which can lead you (eventually) to a
fact known as Fermat's Little Theorem. It is a worthy journey, and you
can learn much along the way.

The length of the repeating part is the smallest number of 9's such
that the denominator divides 9999...999000...0000 evenly. For example,
7 divides 999999 evenly, so the repeating part has length 6.
Furthermore, the digits in the repeating part of 1/7 are the digits of
the quotient 999999/7 = 142857.

1/7 = 142857/999999 = 142857/10^6 + 142857/10^12 + 142857/10^18 + ...
= 0.142857 + 0.000000142857 + 0.000000000000142857 + ...

You will recognize this as a geometric series.

Since 13 is a divisor of 999999, with quotient 76923, you can safely
predict that 1/13 = 0.076923 076923 076923 076923 076923 076923 ...
without needing a high-precision calculator!

Next you probably want to know in advance what number
999...999000...000 is a multiple of some denominator N. This is done
by factoring N as a product of prime powers, which can be done only
one way. They fall into two classes: ones dividing 10 and ones not
dividing 10 (the base of our system of numerals). The first consists
of just {2,5}, and the second is all the other primes. The number of
zeroes in the number in the first line of this paragraph is just the
larger of the two exponents of 2 and 5. That's the easy part! And if
there are no other primes, then that larger exponent E is such that N
is a divisor of 10^E, and the decimal terminates after E decimal
places. 1/N = Q/10^E, where Q = 10^E/N.

The next step is to find for the rest of the primes p dividing into N
evenly what smallest power of 10 has the property that 10^k - 1 is a
multiple of p. That number k is called the order of 10 modulo p. The
most helpful fact about k is that it is a divisor of p - 1. Recall
that for p = 7, we had k = 6, and, sure enough, 6 is a divisor of 7 -
1 = 6. This limits you to just a few possibilities.  There is no easy
way to tell which of these divisors of p - 1 is actually k, you just
have to try them.

The next step is to find the highest power of p dividing 10^k - 1. We
know that it is at least 1, but it may be more.  For example, if p =
3, the divisors of 3-1 = 2 are 1 and 2.  It turns out that k = 1,
because 3 is a divisor of 10^1 - 1 = 9, but, in fact, 3^2 is also a
divisor of 9, too. Call that highest power p^e. Now if the power of p
dividing N is p^n, and n <= e, then the period length of 1/p^n is k.
If, on the other hand, n > e, then the period length of 1/p^n is
k*p^(n-e). Now to get the length of the period of 1/N, take the least
common multiple of the lengths of the periods of 1/p^n, for all primes
other than 2 or 5 dividing N.

Example: Find the length of the period of 1/9450. Start by factoring
9450 = 2 * 3^3 * 5^2 * 7. The number of zeroes will be the larger of 1
and 2 (the exponents of 2 and 5 in this factorization), namely 2. Now
first consider 3^3 = p^n. The order of 10 modulo 3 is 1, and 3^2 is a
divisor of 10^1 - 1 = 9, so e = 2. Since n = 3 > 2, the period length
of 1/3^3 is 1*3^(3-2) = 3. Next consider 7^1 = p^n. The order of 10
modulo 7 is 6, as above, and 7^1 is the largest power of 7 dividing
10^6 - 1 = 999999 = 3^3 * 7 * 11 * 13 * 37, so e = 1. Thus the period
length of 1/7 is 6. Taking the LCM of 3 and 6 gives 6. That tells me
that the number of 9's should be 6, and 9450 must divide evenly into
99999900. Sure enough, it does, and the quotient is 10582. Thus

1/9450 = 10582/99999900 = 0.00 010582 010582 010582 010582...

Notice the 2 digits to the right of the decimal before the repeating
part begins, corresponding to the two zeroes at the end of the number
99999900, corresponding to the larger of the exponents of 2 and 5 in
the factorization of 9450. Similarly,

4567/9450 = 48327994/99999900 = 0.48 328042 328042 328042 328042...

Example: Find the period length of 1/73. Since 73 is prime, we need to
find the order of 10 modulo 73. It must be a divisor of 72, so it
could be 72, 36, 24, 18, 12, 9, 8, 6, 4, 3, 2, or 1. It turns out to
be 8, so k = 8, and 73 divides evenly into 99999999. The period length
must be 8.  The quotient is 1369863, so the decimal expansion must be

1/73 = 0.01369863 01369863 01369863 01369863...

Get the idea?

Proofs of the above facts are a part of a subject called Number
Theory, which you can study as an advanced undergraduate at a college
or university.

- Doctor Rob, The Math Forum
http://mathforum.org/dr.math/
```

```
Date: 05/21/99 at 15:41:35
From: S.J. Lean
Subject: Re: Long numbers

On April 28, 1999, Dr Rob gave me a good reply, except there is no
information on the calculator (I mean, software calculator) I must
find.

For example, I have already look at sevenths, and find tail 142857 --
six digits long. But what is tail length of 1/7 times 1/7, or 1/49?
When I work out it is very interesting:

0.020408163265306122448979591836734693877551 ...

THEN digits repeat. I notice that this is 42 digits long! But 42
happens to be six times seven and maybe it is only a coincidence, but
maybe not. I have an idea that one over a number (n = 7) would give a
tail length of such-and-such, (6 in this case) but that the tail
length of one over the same number SQUARED (n^2 = 49) would turn out
to be the first number TIMES the first tail length? This is MY "little
theory", but how to check it out? I tried some examples and found it
to be true.

But I cannot easily do trial and error without a better calculator, so
how can I see more patterns for my clues? Do you know of any software
for this specialization? I need it to work out some that are dozens of
digits long (hundreds would be even better).

P. Grabowski
```

```
Date: 05/25/99 at 09:55:32
From: Doctor Rob
Subject: Re: Long numbers

Thanks for writing back to Ask Dr. Math!

The problem you are trying to deal with does not require high
precision calculators to solve. I described the solution in a previous
answer. If you insist on using such calculators, here is some

Here is a website with links to lots of on-line calculators:

http://www-sci.lib.uci.edu/HSG/RefCalculators2.html

It sounds to me as if you want a software symbolic computation program
such as MAPLE, MATHEMATICA, MATLAB, GP/PARI, or the like, which
includes high accuracy multiple precision arithmetic. Some of these
are commercial products, which you have to buy. Others are freeware or
shareware. Here is a webpage with links to software for math education
which may be of some help:

http://mathforum.org/mathed/math.software.archives.html

You can use an ordinary 10-digit calculator to do the divisions you
want to do, too. You want to find the decimal expansion of 1/N for
some values of N less than, say, 10000000 = 10^7.  Enter 1000000000
into your calculator. That is your first dividend, D1. Divide by N.
The integer part of the quotient is the first part of the decimal
expansion. Call that Q1. Then enter D1 and subtract Q1*N. That will
give you the remainder R1. Now enter R1 followed by as many 0's as
will fit in your calculator. That is your next dividend D2. Divide by
N. The integer part of the quotient is the next part of the decimal
expansion. Call that Q2. Then enter D2 and subtract Q2*N. That will
give you the remainder R2. Continue this process as long as you like.

Example: Find the decimal expansion of 1/127.
N = 127,
D1 = 1000000000,
D1/N = 1000000000/127 = 7874015.748...
so Q1 = 7874015, and then D1 - Q1*N = R1 = 95.

D2 = 9500000000,
D2/N = 9500000000/127 = 74803149.61...
so Q2 = 74803149, and then D2 - Q2*N = R2 = 77.

D3 = 7700000000,
D3/N = 7700000000/127 = 60629921.25...
so Q3 = 60629921, and then D3 - Q3*N = R3 = 33.

D4 = 3300000000,
D4/N = 3300000000/127 = 25984251.97...
so Q4 = 25984251, and then D4 - Q4*N = R4 = 123.

D5 = 1230000000,
D5/N = 1230000000/127 = 9685039.370...
so Q5 = 9685039, and then D5 - Q5*N = R5 = 47.

D6 = 4700000000,
D6/N = 4700000000/127 = 37007874.01...
so Q6 = 37007874.

The decimal expansion we have found so far is

1/127 = 0.007874015748031496062992125984251968503937 007874...

and you can see the beginning of the second period. The length of the
period is 42. This is because 10^42 - 1 is a multiple of 127, and no
smaller power of 10 has that property. Note that 42 = (127-1)/3.

999999999999999999999999999999999999999999/127 =
7874015748031496062992125984251968503937 exactly.

If N is larger, you get fewer decimal places in the expansion at each
step, so you have to take more steps, but the result is just as valid.
This will not work if N is larger than D1.

- Doctor Rob, The Math Forum
http://mathforum.org/dr.math/
```
Associated Topics:
High School Calculators, Computers
High School Number Theory
High School Sequences, Series
Middle School Fractions

Search the Dr. Math Library:

 Find items containing (put spaces between keywords):   Click only once for faster results: [ Choose "whole words" when searching for a word like age.] all keywords, in any order at least one, that exact phrase parts of words whole words

Submit your own question to Dr. Math
Math Forum Home || Math Library || Quick Reference || Math Forum Search