OFFSET
1,3
COMMENTS
Note that (n-1) == a(n) (mod lambda(n)), where lambda(n) = A002322(n).
For n > 1, a(n) = lambda(n) if and only if n is a prime or a Carmichael number. For n <> 1 and 4, a(n) = n-1 if and only if n is a prime.
For n > 2, a(n) = 1 if and only if n is a squarefree 2-Knodel number.
For n > 3, a(n) = 2 if and only if n is a 3-Knodel number.
FORMULA
MATHEMATICA
a[n_] := Module[{k = 0}, While[!AllTrue[Range[n], PowerMod[#, n - 1, n] == PowerMod[#, k, n] &], k++]; k]; Array[a, 100] (* Amiram Eldar, Dec 11 2019 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Thomas Ordowski, Dec 11 2019
EXTENSIONS
More terms from Amiram Eldar, Dec 11 2019
STATUS
approved