A384237 The number of divisors d of n such that d^d == d (mod n).
1, 2, 2, 2, 2, 3, 2, 2, 2, 3, 2, 4, 2, 3, 3, 2, 2, 3, 2, 3, 3, 3, 2, 3, 2, 3, 2, 4, 2, 6, 2, 2, 3, 3, 2, 4, 2, 3, 3, 3, 2, 4, 2, 3, 3, 3, 2, 3, 2, 3, 3, 3, 2, 3, 3, 4, 3, 3, 2, 4, 2, 3, 3, 2, 4, 5, 2, 3, 3, 3, 2, 3, 2, 3, 3, 3, 2, 4, 2, 4, 2, 3, 2, 6, 3, 3, 3, 3, 2, 5, 3, 3, 3, 3, 3, 2, 2, 3, 2, 3
Offset: 1
Examples
a(2) = 2 because 1^1 = 1 (mod 2) and 2^2 = 2 == 0 (mod 2) where 1 and 2 are divisors of 2.
Programs
-
Magma
[1 + #[d: d in Divisors(n) | Modexp(d, d, n) eq d]: n in [1..100]];
-
Mathematica
a[n_]:=1+Length[Select[Divisors[n],PowerMod[#,#,n]==# &]]; Array[a,100] (* Stefano Spezia, May 25 2025 *)
-
PARI
a(n) = sumdiv(n, d, Mod(d,n)^d == d); \\ Michel Marcus, May 25 2025
-
Python
from sympy import divisors def A384237(n): return 1+sum(1 for d in divisors(n,generator=True) if d
Chai Wah Wu, May 29 2025
Formula
a(n) = 1 + number of proper divisors d of n such that d^(d-1) == 1 (mod n/d). - Chai Wah Wu, May 29 2025