OFFSET
1,5
COMMENTS
If n is a prime number, a(n) = A000720(n) - 1 because the number of distinct residues of k^n (mod n) = n.
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
EXAMPLE
a(7) = 3 because k^7 == 0, 1, 2, 3, 4, 5, 6 (mod 7) including 3 prime residues 2, 3, 5.
MAPLE
for n from 1 to 100 do: W:={}:for k from 0 to n-1 do:z:= irem(k^n, n): if type(z, prime)=true then W:=W union {z}:else fi:od: x:=nops(W): printf(`%d, `, x): od:
MATHEMATICA
Table[Length[Select[Union[Table[Mod[k^n, n], {k, 0, n - 1}]], PrimeQ]], {n, 81}] (* Alonso del Arte, Dec 10 2011 *)
Count[Union[#], _?PrimeQ]&/@Table[PowerMod[k, n, n], {n, 100}, {k, 0, n-1}] (* Harvey P. Dale, Sep 24 2022 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Michel Lagneau, Dec 09 2011
STATUS
approved