In number theory, a kth root of unity modulo n for positive integers k, n ≥ 2, is a root of unity in the ring of integers modulo n; that is, a solution x to the equation (or congruence) x k ≡ 1 ( mod n ) {\displaystyle x^{k}\equiv 1{\pmod {n}}} . If k is the smallest such exponent for x, then x is called a primitive kth root of unity modulo n. See modular arithmetic for notation and terminology.
The roots of unity modulo n are exactly the integers that are coprime with n. In fact, these integers are roots of unity modulo n by Euler's theorem, and the other integers cannot be roots of unity modulo n, because they are zero divisors modulo n.
A primitive root modulo n, is a generator of the group of units of the ring of integers modulo n. There exist primitive roots modulo n if and only if λ ( n ) = φ ( n ) , {\displaystyle \lambda (n)=\varphi (n),} where λ {\displaystyle \lambda } and φ {\displaystyle \varphi } are respectively the Carmichael function and Euler's totient function.
A root of unity modulo n is a primitive kth root of unity modulo n for some divisor k of λ ( n ) , {\displaystyle \lambda (n),} and, conversely, there are primitive kth roots of unity modulo n if and only if k is a divisor of λ ( n ) . {\displaystyle \lambda (n).}