A386409 Number of nonnegative values s < n such that (-s)^s == -s (mod n).
1, 1, 2, 2, 2, 4, 2, 4, 3, 4, 3, 7, 5, 5, 6, 6, 4, 6, 4, 9, 8, 5, 2, 13, 4, 8, 3, 9, 4, 14, 3, 6, 7, 8, 12, 11, 3, 7, 10, 17, 5, 16, 6, 9, 10, 5, 2, 19, 7, 8, 10, 13, 3, 6, 11, 18, 11, 7, 3, 27, 5, 7, 14, 10, 16, 17, 5, 13, 7, 21, 4, 21, 5, 6, 14, 12, 12, 21, 5, 27, 6, 11, 3, 29, 16, 10, 9, 19, 4, 23
Offset: 1
Programs
-
Magma
[#[s: s in [0..n-1] | Modexp(-s, s, n) eq n-s mod n]: n in [1..90]];
-
Mathematica
a[n_] := Count[Range[0, n-1], ?(PowerMod[-#, #, n] == n - # &)]; a[1] = 1; Array[a, 100] (* _Amiram Eldar, Jul 21 2025 *)
-
PARI
a(n) = sum(s=0, n-1, Mod(-s, n) == Mod(-s, n)^s); \\ Michel Marcus, Aug 22 2025
Extensions
a(1) corrected by Andrew Howroyd, Aug 22 2025