# Carmichael function

In number theory, the Carmichael function of a positive integer n, denoted $\lambda(n)$, is defined as the smallest positive integer m such that

$a^m \equiv 1 \pmod{n}$

for every integer a that is coprime to n. In more algebraic terms, it defines the exponent of the multiplicative group of integers modulo n. The Carmichael function is also known as the reduced totient function or the least universal exponent function, and is sometimes also denoted $\psi(n)$.

The first 36 values of $\lambda(n)$ (sequence A002322 in OEIS) compared to Euler's totient function $\varphi$. (in bold if they are different)

n 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
$\lambda(n)$ 1 1 2 2 4 2 6 2 6 4 10 2 12 6 4 4 16 6 18 4 6 10 22 2 20 12 18 6 28 4 30 8 10 16 12 6
$\varphi(n)$ 1 1 2 2 4 2 6 4 6 4 10 4 12 6 8 8 16 6 18 8 12 10 22 8 20 12 18 12 28 8 30 16 20 16 24 12

## Numeric example

72 = 49 ≡ 1 (mod 8) because 7 and 8 are coprime (their greatest common divisor equals 1; they have no common factors) and the value of Carmichael's function at 8 is 2. Euler's totient function is 4 at 8 because there are 4 numbers lesser than and coprime to 8 (1, 3, 5, and 7). Whilst it is true that 74 = 2401 ≡ 1 (mod 8), as shown by Euler's theorem, raising 7 to the fourth power is unnecessary because the Carmichael function indicates that 7 squared equals 1 (mod 8). Raising 7 to exponents greater than 2 only repeats the cycle 7, 1, 7, 1, ... . Because the same holds true for 3 and 5, the Carmichael number is 2 rather than 4. [1]

## Carmichael's theorem

For a power of an odd prime, twice the power of an odd prime, and for 2 and 4, λ(n) is equal to the Euler totient φ(n); for powers of 2 greater than 4 it is equal to one half of the Euler totient:

$\lambda(n) = \begin{cases} \;\;\varphi(n) &\mbox{if }n = 2,3,4,5,6,7,9,10,11,13,14,17,19,22,23,25,26,27,29\dots\\ \tfrac12\varphi(n)&\text{if }n=8,16,32,64,128,256\dots \end{cases}$

Euler's function for prime powers is given by

$\varphi(p^k) = p^{k-1}(p-1).\;$

By the fundamental theorem of arithmetic any n > 1 can be written in a unique way

$n= p_1^{a_1}p_2^{a_2} \dots p_{\omega(n)}^{a_{\omega(n)}}$

where p1 < p2 < ... < pω are primes and the ai > 0. (n = 1 corresponds to the empty product.)

For general n, λ(n) is the least common multiple of λ of each of its prime power factors:

$\lambda(n) = \operatorname{lcm}[\lambda(p_1^{a_1}),\;\lambda(p_2^{a_2}),\dots,\lambda(p_{\omega(n)}^{a_{\omega(n)}}) ].$

Carmichael's theorem states that if a is coprime to n, then

$a^{\lambda(n)} \equiv 1 \pmod{n},$

where $\lambda$ is the Carmichael function defined above. In other words, it asserts the correctness of the formulas. This can be proven by considering any primitive root modulo n and the Chinese remainder theorem.

## Hierarchy of results

Since λ(n) divides φ(n), Euler's totient function (the quotients are listed in ), the Carmichael function is a stronger result than the classical Euler's theorem. Clearly Carmichael's theorem is related to Euler's theorem, because the exponent of a finite abelian group must divide the order of the group, by elementary group theory. The two functions differ already in small cases: λ(15) = 4 while φ(15) = 8 (see for the associated n).

Fermat's little theorem is the special case of Euler's theorem in which n is a prime number p. Carmichael's theorem for a prime p gives the same result, because the group in question is a cyclic group for which the order and exponent are both p − 1.

## Properties of the Carmichael function

### Divisibility

$a|b \Rightarrow \lambda(a)|\lambda(b)$

### Composition

For all positive integers $a$ and $b$ it holds

$\lambda(\mathrm{lcm}(a,b)) = \mathrm{lcm}( \lambda(a), \lambda(b) )$ .

This is an immediate consequence of the recursive definition of the Carmichael function.

### Primitive m-th roots of unity

Let $a$ and $n$ be coprime and let $m$ be the smallest exponent with $a^m \equiv 1 \pmod{n}$, then it holds

$m | \lambda(n)$ .

That is, the orders of primitive roots of unity in the ring of integers modulo $n$ are divisors of $\lambda(n)$.

### Exponential cycle length

For a number $n$ with maximum prime exponent of $x_{max}$ under prime factorization, then for all $a$ (including those not co-prime to $n$) and all $k \geq x_{max}$,

$a^k \equiv a^{k+\lambda(n)} \pmod n$

In particular, for squarefree $n$ ($x_{max} = 1$), for all $a$

$a \equiv a^{\lambda(n)+1} \pmod n$

### Average and typical value

For any x > 16, and a constant B:

$\frac{1}{x} \sum_{n \leq x} \lambda (n) = \frac{x}{\ln x} e^{B (1+o(1)) \ln\ln x / (\ln\ln\ln x) }$.[2][3]

Here

$B = e^{-\gamma} \prod_p \left({1 - \frac{1}{(p-1)^2(p+1)}}\right) \approx 0.34537 \ .$

For all numbers N and all except o(N) positive integers n ≤ N:

$\lambda(n) = n / (\ln n)^{\ln\ln\ln n + A + o(1)}\,$

where A is a constant,[3][4]

$A = -1 + \sum_p \frac{\log p}{(p-1)^2} \approx 0.2269688 \ .$

### Lower bounds

For any sufficiently large number N and for any $\Delta \geq (\ln\ln N)^3$, there are at most

$Ne^{-0.69(\Delta\ln\Delta)^{1/3}}$

positive integers $n \leq N$ such that $\lambda(n) \leq ne^{-\Delta}$.[5]

For any sequence $n_1 of positive integers, any constant $0, and any sufficiently large i:

$\lambda(n_i) > (\ln n_i)^{c\ln\ln\ln n_i}$.[6][7]

### Small values

For a constant c and any sufficiently large positive A, there exists an integer $n>A$ such that $\lambda(n)<(\ln A)^{c\ln\ln\ln A}$.[7] Moreover, n is of the form

$n=\prod_{(q-1)|m \text{ and } q \text{ is prime}}q$

for some square-free integer $m<(\ln A)^{c\ln\ln\ln A}$.[6]

### Image of the function

The set of values of the Carmichael function has counting function

$\frac{x}{(\log x)^{\eta+o(1)}} \ ,$

where η=1−(1+loglog2)/(log2)=0.08607….[8]