0
$\begingroup$

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?

  • 1
    Note that if the cycle is $p-1$, this is basically equivalent to $$\operatorname{ord}_{p}10=p-1$$ Or that $10$ is a primitive root modulo $p$.2017-02-19
  • 0
    @S.C.B. I am a high school student what does $ord$ and primitive root mean?2017-02-19
  • 0
    The order of $a$ modulo $p$ (denoted $ord_p(a)$) is the smallest positive integer $n$ with $a^n\equiv 1\mod p$2017-02-20
  • 0
    A primitive root modulo $n$ is a number $a$ with $ord_n(a)=\phi(n)$, where $\phi(n)$ is the totient function (it gives the number of integers from $1$ to $n-1$, which are coprime to $n$)2017-02-20
  • 0
    If $p$ is prime, we have $\phi(p)=p-1$, so a primitive root modulo $p$ is a number $a$ with $ord_p(a)=p-1$2017-02-20
  • 0
    @Peter could you give an answer with full explain?2017-02-20
  • 0
    See https://oeis.org/A0019132018-12-02

2 Answers 2

2

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
?
  • 3
    It may be illuminating to also print out the value of $(p-1)/ord_p(10)$, which makes it easier to visualize the near misses. Artin's conjecture predicts that 1s will comprise about 37% of the primes, and I'm sure similar predictions can be made for other small values of $(p-1)/ord_p(10)$.2017-02-20
  • 0
    If we miss $p-1$, the maximum possible value is $\frac{p-1}{2}$. There are no "near misses".2017-02-20
  • 0
    That is precisely why I advocate showing $(p-1)/ord_p(10)$. Judged by period length, $\frac{p-1}{2}$ looks very far from $p-1$, yet in actuality it's as near as one can get without being equal to $p-1$. The complementary value seems to be the natural statistic here.2017-02-20
  • 0
    could you give a proof why the cycle length is given with that formula?2017-02-20
  • 0
    First of all, because $p$ is coprime to $10$, we have a full-period. Something like $\frac{1}{6}=0.1\overline 6$ can be ruled out. We start with $10$ and divide by $p$ giving residue $10$ modulo $p$. The decimal expansion becomes periodic , when this residue occurs again. So, we must have $10^l\equiv 10\mod p$, which is equivalent to $10^{l-1}\equiv 1\mod p$. The length of the period is $l-1$ because in the first step we have the same residue as in the $l$-th step.2017-02-20
1

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
?
  • 0
    Where should I run the program?2017-02-21
  • 0
    It is PARI/GP, a free and powerful calculator2017-02-22