OFFSET
1,1
COMMENTS
Smallest k > n coprime to n such that n^k == n^n (mod k).
If a(n) is a prime p, then n^(n-1) == 1 (mod p).
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..1000
MATHEMATICA
a[n_] := Module[{k = n + 1}, While[PowerMod[n, k - n, k] != 1, k++]; k]; Array[a, 60] (* Amiram Eldar, Aug 10 2021 *)
PROG
(PARI) a(n) = my(k=n+1); while (Mod(n, k)^(k-n) != 1, k++); k; \\ Michel Marcus, Aug 10 2021
(Python)
def A346988(n):
k, kn = n+1, 1
while True:
if pow(n, kn, k) == 1:
return k
k += 1
kn += 1 # Chai Wah Wu, Aug 28 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Thomas Ordowski, Aug 10 2021
EXTENSIONS
More terms from Amiram Eldar, Aug 10 2021
STATUS
approved