Take the 2-minute tour ×
MathOverflow is a question and answer site for professional mathematicians. It's 100% free, no registration required.

If you divide 1 by 7, you'll of course have a repeating decimal sequence of 142857. This of course repeats forever. Are there any scenarios where a quotient seems to repeat forever, but then changes at some point? Is this even possible? I'm not a mathematician (obviously), but rather a programmer. The question came up when I was thinking of a programmatic way to determine whether a division result is repeating.

Example (not real of course):


P.S. I can't even find an appropriate tag for this question, so feel free to edit my tags.

share|improve this question

closed as off-topic by Ricardo Andrade, darij grinberg, Karl Schwede, Eric Wofsey, Andrey Rekalo Sep 24 '13 at 7:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be about research level mathematics within the scope defined in the help center." – Ricardo Andrade, darij grinberg, Karl Schwede, Eric Wofsey, Andrey Rekalo
If this question can be reworded to fit the rules in the help center, please edit the question.

I don't follow. It is impossible to determine whether a number is rational by looking at any finite sequence of its digits. –  Qiaochu Yuan Oct 2 '10 at 8:03
@Qiaochu Yuan, I agree with you, as you'll see in my answer below. If, however, Orokusaki is generating his sequence as the result of dividing $a \div b$, where $a,b \in \mathbb{Z}$, then obviously $a \div b$ is rational and will ultimately repeat. ... though it may take $b-1$ digits before it does so... –  sleepless in beantown Oct 2 '10 at 10:08

2 Answers 2

up vote -1 down vote accepted

If you want to check if the result of the division is repeating you can make use of this (from http://www.mathlesstraveled.com/?p=134):

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.

So in your example I think you would only need to check up to the 7th digit and for sleepless's example, you would only need to check up the 13th digit.

I'm also a programmer and not a mathematician so I probably have this all wrong :)

share|improve this answer
@mattjames - awesome, thanks for getting that for me. –  orokusaki Oct 2 '10 at 4:07
@mattjames, note that the repeating fraction $1/7$ (which has $q$=7) repeats the six digits 142857. Six is $q-1$, even though the numeral $7$ is one digit long. If you didn't know that $a/(10^{n}-1)$ was going to repeat after $n$ digits, you'd have to calculate it out to $10^n-1$ digits to check. For example, take $1 \div 103$. It requires checking 102 digits of the decimal expansion to check for the repeat length. Or for $a/(10^{n}-3)$, where $a,n \in \mathbb{Z}$, all $10^{n}-3$ digits would have to assessed to determine repeat length. That's a lot of digits, increasing exponentially in n –  sleepless in beantown Oct 2 '10 at 9:36
@mattjames, technically, you'd have to check the $121212121213 \div 999999999999$ example out to $999999999998$ digits to make sure of the repeat length if it weren't for the facts described below. I can't predict how many digits are in the repeat of $121212121213 \div 999999999997$ beyond saying that it will repeat in less than $999999999997$ digits. That's a very large number of digits to expand out to and check for repeats. –  sleepless in beantown Oct 2 '10 at 10:07

There is no such thing as a non-repeating division sequence if the quotient is formed by the division of two integers or by the divsion of two rational numbers.

Orokusaki, any rational sequence of any length (length=$n$) at all can be constructed as a fraction of the form

$$ \frac{\sum_{i=1}^{i=n} d_i 10^{i-1}}{10^n -1} $$

where $d_i$ is the $i$-th digit counting from the right (the lowermost powers of 10).

For example, the fractional sequence repeating 12 as 0.121212... can be constructed as $12/99$.

The repeating decimal 0.121212121213 which continually repeats 12 five times followed by 13 once is the fraction


So the fact that you have $m$ repeats of a $n$-digit length sequence is not a guarantee that the repeats will continue ad infinitum.

Sequences which repeat a sequence a fixed number of times followed by infinite repeats of another sequence can also be constructed in a similar fashion.

If, however, you are generating this digit sequence as the quotient of two integer values (call them $a,b, a\in \mathbb{Z}, b \in \mathbb{Z}$), then you are guaranteed that the sequence will repeat. This is because all rational fractions of integers can be represented in the fraction format $c/({10^n-1})$ with $c \in \mathbb{Z}$ as described above, though it is not always easy to determine what length of repeat may occur.

share|improve this answer
Coo, I can read that ∑ thing just like any other word :| –  orokusaki Oct 2 '10 at 3:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.