How long before digits repeat

Hey I'm pretty new here, this is a cool site. Sorry if this has been asked before.

When I carry out a division to get the decimal representation of a rational number n/m, is there a way to figure out how far out it will go before the representation terminates in zeros or before it starts to repeat? Is there a name for this?

When I carry out a division to get the decimal representation of a rational number n/m, is there a way to figure out how far out it will go before the representation terminates in zeros or before it starts to repeat? Is there a name for this?

Sloane's sequence A114206, which is related to http://www.research.att.com/~njas/sequences/A114205" [Broken]

Write decimal expansion of 1/n as 0.PPP...PQQQ..., where QQQ... is the cyclic part. If the expansion does not terminate, any leading 0's in QQQ... are regarded as being at the end of the PPP...P part. Sequence gives PPP...P, right justified, with leading zeros omitted.

Hey I'm pretty new here, this is a cool site. Sorry if this has been asked before.

When I carry out a division to get the decimal representation of a rational number n/m, is there a way to figure out how far out it will go before the representation terminates in zeros or before it starts to repeat? Is there a name for this?

Suppose n/m has a decimal representation that repeats itself with a period of q. If n/m > 1/10, then multiplying n/m by 10^p, would shift the decilas p laces and after the decmal place all the numbers would be the same. so, the factional part of n/m and the fractional pat of 10^p n/m are the same. So, this means that if you divide n by m then the remainder will be the same as when you divide 10^p n by m:

n Mod m = n 10^p Mod m

If n and m are relatively prime you can divie both sides by n:

10^p Mod m = 1

If 10 is relatively prime to m, then Euler's theorem says that we always have:

10^(phi(m)) Mod m = 1

where phi(m) is the number of integers smaller than m that are relatively prime to m, which can be computed from:

phi(m) = m product over all primes q that divide m of (1-1/q)

p is the smallest number to which you have to raise 10 to get 1. This is called the order of 10. It then follows that p divides phi(m). (if not then you can construct a smaller number p' such that 10^p' Mod m = 1).

If m is prime number than phi(m) = m-1. So, e.g. phi(7) = 6. So, the period of 1/7 must be a divisor of 6. It is in fact 6: 1/7 = 0.1428571428...

Does it have to be so complicated? Apply the http://en.wikipedia.org/wiki/Pigeonhole_principle" [Broken]. The decimal expansion of [itex] \frac n m [/itex] must repeat within m digits.

The denominator determines the possible number of remainders available in the long division process. Once you have either cycled through all of the possible remainders or repeat a remainder the decimal expansion must repeat.