(where p does not divideb) gives a cyclic number. Therefore, the base b expansion of repeats the digits of the corresponding cyclic number infinitely, as does that of with rotation of the digits for any a between 1 and p − 1. The cyclic number corresponding to prime p will possess p − 1 digits if and only ifp is a full reptend prime. That is, the multiplicative orderordpb = p − 1, which is equivalent to b being a primitive root modulo p.
The term "long prime" was used by John Conway and Richard Guy in their Book of Numbers. Confusingly, Sloane's OEIS refers to these primes as "cyclic numbers".
Base 10
Base 10 may be assumed if no base is specified, in which case the expansion of the number is called a repeating decimal. In base 10, if a full reptend prime ends in the digit 1, then each digit 0, 1, ..., 9 appears in the reptend the same number of times as each other digit.[1]: 166 (For such primes in base 10, see OEIS: A073761.) In fact, in base b, if a full reptend prime ends in the digit 1, then each digit 0, 1, ..., b − 1 appears in the repetend the same number of times as each other digit, but no such prime exists when b = 12, since every full reptend prime in base 12 ends in the digit 5 or 7 in the same base. Generally, no such prime exists when b is congruent to 0 or 1 modulo 4.
The values of p for which this formula produces cyclic numbers in decimal are:
These sequences of period p − 1 have an autocorrelation function that has a negative peak of −1 for shift of . The randomness of these sequences has been examined by diehard tests.[2]
Binary full reptend prime sequences (also called maximum-length decimal sequences) have found cryptographic and error-correction coding applications.[3] In these applications, repeating decimals to base 2 are generally used which gives rise to binary sequences. The maximum length binary sequence for (when 2 is a primitive root of p) is given by Kak.[4]
Francis, Richard L.; "Mathematical Haystacks: Another Look at Repunit Numbers"; in The College Mathematics Journal, Vol. 19, No. 3. (May, 1988), pp. 240–246.