I have a few questions about cyclic numbers in base $b$ ($b = 2$ in particular). We are dealing here with primes $p$ such that the length of the period in the decimal (more precisely base $b$) representation of $1/p$ is equal to $p-1$. For instance, in base $10$, primes $p=7, 17, 19, 23, 29, 47, 59, \cdots$ have this property. In base $2$, $p = 3, 5, 11, 13, 19, 29,\cdots$ have this property.

My questions are:

  • Does the period of $1/p$, for large $p$'s satisfying this property (having a period of length $p-1$), look random?
  • Can you compute the first $100,000$ primes in base $2$ satisfying this property?

Final purpose

The final purpose of this exercise is to check whether a number such as $e^{-1}$ has its digits uniformly distributed, by approximating $e^{-1}$ with a sequence $\{x_n\}$ built as follows: $x_n = b^n/q_n$ where $q_n$ is the prime in question that minimizes the approximation error. Here $b$ is the base. The idea is that such a converging sequence (or sub-sequence) exists for a number such as $e^{-1}$ ($x_n \rightarrow e^{-1})$ but maybe not for a rational number. As $e^{-1}$ is approximated by rational numbers of increasing period $n-1$, and as long as the period look random, at the limit, we would conclude that the digits of $e^{-1}$ are uniformly distributed.

  • 2
    $\begingroup$ Here are the first $10000$ such primes. What do you mean by "look random"? $\endgroup$ Jul 16, 2019 at 18:38
  • $\begingroup$ Thanks, very useful! By "random", I mean as the period grows to infinity, the proportion of 0's, 1's, 2's and so on (in the period) is almost the same. $\endgroup$ Jul 16, 2019 at 19:52
  • 1
    $\begingroup$ Heuristically your claim is true. I tested for various bases with the largest prime in the above list. Although I would have no idea how one could prove this. $\endgroup$ Jul 16, 2019 at 19:58
  • $\begingroup$ I am wondering if the fact that $(n+1)^n / n^n \rightarrow e$ might help. $\endgroup$ Jul 16, 2019 at 23:54
  • $\begingroup$ @VincentGranville Checking whether $e^{-1}$ , for example , has digits uniformly distributed, is almost surely utterly hopeless. No matter how precise we can calculate $e^{-1}$ , we do not even know whether the digits $0-9$ all appear infinite many times. Perhaps, only two digits appear infinite many times, noone knows. The situation won't be better in base $2$ or other bases. $\endgroup$
    – Peter
    Jul 17, 2019 at 5:36

1 Answer 1


I know this is an old question. I've been exploring characteristics of these lately. Specifically in base 10 mostly. I'm going to state some things I stumbled on without explanation first.

For reptend primes p, there is a period of p-1 digits. The (p-1)/2 digit will be p-1. This means that if (10**((p-1)/2)) % p == p-1, it's a candidate for being a reptend prime. I'm pretty sure you can change the base and do this same process to find candidates for long periods primes in other cases.

To confirm your prime is a reptend prime(or other base long period prime), you also have to test for multiplicative order mod p. If it passes, it's a long period prime.

Reptend primes (p-1)%10 have an equal quantity of each digit in their decimal expansions. I can explain further if anyone is interested.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .