OFFSET
1,4
LINKS
Amiram Eldar, Table of n, a(n) for n = 1..1001 (adapted to offset 1 by Sidney Cadot).
MATHEMATICA
Table[(k=p-1; While[MultiplicativeOrder[k, p]!=p-1, k--]; k)-PrimitiveRoot@p, {p, Prime@Range@100}] (* Giorgos Kalogeropoulos, Sep 28 2023 *)
PROG
(PARI) a(n)=my(p=prime(n)); forstep(r=p-1, 2, -1, if(znorder(Mod(r, p))==p-1, return(r-lift(znprimroot(p)))));
vector(66, n, a(n)) \\ Joerg Arndt, Sep 29 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Robert G. Wilson v, Apr 21 2007
EXTENSIONS
a(1)=0 inserted by Georg Fischer, Dec 11 2022
STATUS
approved