Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

For the period of something like $1/d$ where $d$ is a positive integer, I saw an algorithm repeatedly doing:

$$\begin{align*}r &= 1\\ r &= 10r \bmod d \quad\text{ (until } r = 1) \end{align*}$$

and the number of steps was the period.

share|improve this question
1  
The period is the smallest positive $k$ such that $10^k\equiv 1\pmod{d}$. Of course we must put restrictions on $d$. Assume that neither $2$ nor $5$ divides $d$. –  André Nicolas May 26 '12 at 22:17
    
It does not work for $d=6$ –  Henry May 26 '12 at 22:20
    
Ah yes I had it wrong but it was just long division. –  Palace Chan May 27 '12 at 1:00
add comment

1 Answer 1

up vote 4 down vote accepted

This is just long division. Once you reach the end you take the remainder over, put a zero next to it and repeat the process, eg:

$$ 2/5 = (2.0)/5 = 0.4 $$

So in this case since we are doing $1/d$ we start with one. How many times this process is repeated is just how many times we carried the remainder over which is the length of the decimal.

share|improve this answer
    
Ah you're exactly right. –  Palace Chan May 27 '12 at 0:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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