For which prime numbers $p$ does the decimal for $\frac{1}{p}$ have cycle length $p-1$?

1k Views Asked by At

For which prime numbers $p$ does the decimal for $\frac{1}{p}$ have cycle length $p-1$? I started with some simple examples to find an idea to solve:

$\frac{1}{2}=0.5,\frac{1}{3}=\overline{3},\frac{1}{5}=0.2,\frac{1}{7}=0.\overline{142857},\frac{1}{11}=0.\overline{09},\frac{1}{13}=0.\overline{0769230}$

Here I only had $7$ Then I can't find idea for solution. Any hints?

2

There are 2 best solutions below

5
On BEST ANSWER

Let $p$ be a prime number different from $2$ and $5$. This implies that $p$ is coprime to $10$.

Fermat's little theorem states that $$10^{p-1}\equiv 1\mod p$$ is satisfied. If for every prime factor $q$ of $p-1$, we have $$10^{\frac{p-1}{q}}\ne 1\mod p$$ we can conlude that $p-1$ is the smallest exponent such that the above equivalence holds.

For example : $$p=17$$ $$p-1=2^4$$ $$3^8\equiv 16\mod 17$$

So, $10$ is a primitive root modulo $17$, so the period has length $16$

$$p=31$$ $$p-1=2\cdot 3\cdot 5$$ $$10^{15}\equiv 1\mod 31$$

So, $10$ is not a primitive root modulo $31$. The period has length $15$ in this case.

In general, the length of the period is $ord_p(10)$

The period lengths for the primes upto $200$ :

? forprime(j=1,200,if(gcd(j,10)==1,print(j,"   ",znorder(Mod(10,j)))))
3   1
7   6
11   2
13   6
17   16
19   18
23   22
29   28
31   15
37   3
41   5
43   21
47   46
53   13
59   58
61   60
67   33
71   35
73   8
79   13
83   41
89   44
97   96
101   4
103   34
107   53
109   108
113   112
127   42
131   130
137   8
139   46
149   148
151   75
157   78
163   81
167   166
173   43
179   178
181   180
191   95
193   192
197   98
199   99
?
2
On

The primes upto $1000$ with period length $p-1$ are :

? q=0;forprime(s=1,1000,if(gcd(s,10)==1,if(znorder(Mod(10,s))==s-1,print1(s," ")
;q=q+1;if(Mod(q,18)==0,print))))
7 17 19 23 29 47 59 61 97 109 113 131 149 167 179 181 193 223
229 233 257 263 269 313 337 367 379 383 389 419 433 461 487 491 499 503
509 541 571 577 593 619 647 659 701 709 727 743 811 821 823 857 863 887
937 941 953 971 977 983
?