If $n$ is a positive integer and $(n,a)=1$ then $x = \phi(n)$ is a solution of the congruence $a^{x} \equiv 1 (\textrm{mod}\ n)$ where $\phi$ is the Euler's totient function. However there could be one or more smaller exponents satisfying the above congruence for all $(n,a)=1$. E.g. if $\gcd(a,123) = 1$ then, $a^{40} \equiv 1 (\textrm{mod}\ 123)$. Clearly $40 < \phi(123) = 80$.
We denote by $l(n)$ the lowest exponent such that $a^{l(n)} \equiv 1 (\textrm{mod}\ n)$ for all $a$ satisfying $(n,a)=1$. Trivially $l(n) $satisfies the following conditions
- $l(n) \le \phi(n)$
- $l(n) \mid \phi(n)$
- $l(p) = \phi(p) = p-1,$ if $p$ is a prime
Question: We have the closed form representation of $\phi(n)$ in terms of the prime factors of $n$. Is there a closed form representation of $l(n)$?
This is called the Carmichael function and is usually denoted by $\lambda(n)$.
A "closed form" is that it is $$\lambda(n)=\operatorname{lcm}_{p \text{ prime}} \{\varphi(p^{v_p})\}=\operatorname{lcm}_{p \text{ prime}} \{(p-1)p^{v_p-1})\}$$ where $v_p$ is the exponent of $p$ in $n$ that is $p^{v_p}\mid n$ yet $p^{v_p+1}\nmid n$.
Note the LCM is only formally over infinitely many numbers. You could also write it as $$\operatorname{lcm} \{(p_1-1)p^{v_1-1}), \dots, (p_k-1)p^{v_k-1}) \}$$ where $n= p_1^{k_1} \dots p_k^{k_p}$ with distinct primes $p_i$.