OFFSET
1,2
COMMENTS
a(n) is the smallest term in row n of A317706.
Equivalently, a(n) is the least primitive root k modulo p = prime(n) such that k^(p-1) == 1 (mod p^2); that is, the least primitive root modulo p to which p is a Wieferich prime.
No perfect square occurs as a value, since a square is never a primitive root of an odd prime. Apparently the only perfect power that occurs, other than a(1) = 1, is a(2) = 8.
It appears that every positive integer that is not a perfect power occurs in the sequence. The value 2 does not occur for any prime below 2^64; the value 3 first occurs at the prime 1006003, the value 5 at 40487, and the value 6 at 66161.
LINKS
Daniel Okwor, Table of n, a(n) for n = 1..1007
EXAMPLE
For n = 2, p = 3: 2 and 5 are primitive roots modulo 3 that are also primitive roots modulo 9, but 8 is a primitive root modulo 3 (8 == 2 (mod 3)) and not modulo 9, since 8^2 = 64 == 1 (mod 9). As 8 is the smallest such k, a(2) = 8.
PROG
(PARI) a(n) = my(p=prime(n)); for(k=1, oo, if(gcd(k, p)==1 && znorder(Mod(k, p))==p-1 && Mod(k, p^2)^(p-1)==1, return(k)));
(Python)
from sympy import prime, n_order
from math import gcd
def a(n):
p = prime(n); k = 1
while not (gcd(k, p)==1 and n_order(k, p)==p-1 and pow(k, p-1, p*p)==1): k += 1
return k
CROSSREFS
KEYWORD
nonn,easy,new
AUTHOR
Daniel Okwor and Eric Chen, Jul 12 2026
STATUS
approved
