Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How long before digits repeat

  1. Jun 11, 2008 #1
    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?
  2. jcsd
  3. Jun 11, 2008 #2

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    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.

    Comment: b(n) = A114206(n) gives the length of P (including leading zeros), c(n) = A036275(n) gives the smallest cycle in QQQ... (including terminating zeros), and d(n) = A051626(n) gives the length of that cycle.
    Thus 1/n = 10^(-b(n)) * ( a(n) + c(n)/(10^d(n) - 1) ). When c(n)=d(n)=0, the fraction c(n)/(10^d(n) - 1), which is 0/0, evaluates (by definition) to 0.​

    Link to http://www.research.att.com/~njas/sequences/A114206" [Broken].
    Last edited by a moderator: May 3, 2017
  4. Jun 11, 2008 #3

    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...
  5. Jun 11, 2008 #4

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    Count: You described the period (length) of the recurring decimal, not the length of the leading (nonperiodic) part of the decimal expansion.
  6. Jun 12, 2008 #5


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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.
    Last edited by a moderator: May 3, 2017
  7. Jun 12, 2008 #6
    I see! I didn't read the question well. :smile:
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook