OFFSET
1,1
COMMENTS
Main diagonal of A244249.
There are exactly p-1 residue classes b mod p^2 for which b^(p-1) == 1 (mod p^2), of which p-2 will be greater than 1. p-2 > n for n > 3, so a(n) < prime(n)^2 for n > 2 (case n = 3 is fortuitous). - Charles R Greathouse IV, Jun 23 2021
LINKS
Robert Israel, Table of n, a(n) for n = 1..1000
FORMULA
a(n) < prime(n)^2 for n > 2, see comments. - Charles R Greathouse IV, Jun 23 2021
EXAMPLE
For n=2, prime(2)=3, 10^1 == 1 (mod 9), 10^2 == 1 (mod 9), a(2) = 10. - N. J. A. Sloane, Jan 14 2017
MAPLE
f:= proc(n) local p, S, nS, r;
p:= ithprime(n);
S:= sort(map(t -> rhs(op(t)), [msolve(b^(p-1)=1, p^2)]));
nS:= nops(S);
r:= (n mod nS)+1;
S[r] + (n+1-r)/nS*p^2;
end proc:
map(f, [$1..100]); # Robert Israel, Jan 09 2017
MATHEMATICA
Table[Function[p, Select[Range[p^2 + 1], PowerMod[#, p - 1, p^2] == 1 &][[n + 1]]]@ Prime@ n, {n, 47}] (* Michael De Vlieger, Jan 09 2017 *)
PROG
(PARI) base(p, n) = my(b=2, i=0); while(1, if(Mod(b, p^2)^(p-1)==1, i++); if(i==n, return(b)); b++)
a(n) = base(prime(n), n)
CROSSREFS
KEYWORD
nonn
AUTHOR
Felix Fröhlich, Jan 07 2017
STATUS
approved