Number Theory: Euler's and Carmichael's Totient, Euler's Theorem

17 Dec 2021


§ Motivation

The Totient function is used in cryptosystems like RSA and is useful in computing number theoretic problems.

§ Euler's Totient Function

Euler's Totient Function

Euler's totient function is typically denoted using φ(x)\varphi(x), defined as

φ(n)={0k<n:(k,n)=1}.\varphi(n) = \vert\{0 \leq k \lt n : (k, n) = 1\}\vert.

Or, φ(n)\varphi(n) is the number of non-negative numbers strictly less than nn that are co-prime with nn.

Properties:

  • If pPp \in \mathbb{P}, then φ(p)=p1\varphi\left(p\right) = p-1
  • If pPp \in \mathbb{P}, then φ(pk)=pk1(p1)\varphi\left(p^k\right) = p^{k-1}(p-1)
    • In the case that p=2p = 2, it simply becomes pk1p^{k-1}. This fact is useful in implementing the Totient function as it allows us to use bit operations.
  • If p,qNp, q \in \mathbb{N} and (p,q)=1(p, q) = 1, then φ(pq)=φ(p)φ(q)\varphi(pq) = \varphi(p)\cdot\varphi(q) (multiplicative)

Multiplicative Property

To reiterate: If p,qNp, q \in \mathbb{N} and (p,q)=1(p, q) = 1, then

φ(pq)=φ(p)φ(q).\varphi(p \cdot q) = \varphi(p)\cdot\varphi(q).

Any number aNa \in \mathbb{N} can be written as a factorization of mm primes,

a=i=0mqiei.a = \prod_{i = 0}^{m} q_i^{e_i}.

Then, φ(a)\varphi(a) can be computed as:

φ(a)=i=0mφ(qiei)=i=0m[(qi)ei1(qi1)]\begin{align*} \varphi(a) &= \prod_{i = 0}^{m} \varphi\left(q_i^{e_i}\right)\\ &= \prod_{i = 0}^{m} \left[(q_i)^{e_i - 1}(q_i - 1)\right] \end{align*}

§ Euler's Theorem

The following lemma is used in the proof of Euler's theorem.

If (a,b)=1(a, b) = 1 and (b,c)=1(b, c) = 1, then (ac,b)=1(ac, b) = 1.

Write all three numbers in terms of their prime factorization and observe that acac shares no common prime factors with bb.

Euler's Theorem

Let (a,n)=1(a, n) = 1, then

aφ(n)n1.a^{\varphi(n)} \equiv_n 1.

Consider the numbers ka(modn)ka \pmod{n} where (k,n)=1(k, n) = 1 and 1k<n1 \leq k \lt n. If jankaja \equiv_n ka, then another way to say this is n(jk)an \vert (j-k)a. Since (a,n)=1(a, n) = 1, we get that n(jk)n \vert (j - k), which means jk=0j - k = 0, so jj must equal kk. Hence, the elements in the sequence given by:

ka(modn), where (k,n)=1 and 1k<n,ka \pmod{n}, \text{ where } (k, n) = 1 \text{ and } 1 \leq k \lt n,

are all distinct, meaning

(j,n)=1kan(l,n)=1l\prod_{(j,n) = 1} ka \equiv_n \prod_{(l, n) = 1} l

for l,j[0n)l, j \in [0\dots n), since each element jaja is congruent to a remainder ll with (l,n)=1(l, n) = 1.

Notice that the left hand side is just ((j,n)=1l)aφ(n)\left(\prod_{(j,n)=1} l\right)a^{\varphi(n)}. Since each term in the product is coprime with nn, we can cancel (j,n)=1l\prod_{(j,n)=1} l from both sides and obtain

aφ(n)n1.a^{\varphi(n)} \equiv_n 1.

Fermat's Little Theorem

In the specific case of Euler's theorem where pp is prime, we get that

ap11(modp).a^{p-1} \equiv 1 \pmod{p}.

One example of Euler's theorem being applied is in exponentation:

gx(modn)g^x \pmod{n}

in cases where x>φ(n)x > \varphi(n), we can reduce this problem to be

gxg(xmodφ(n))(modn).g^{x} \equiv g^{(x \mod{\varphi(n)})} \pmod{n}.

Furthermore, observe

gabg(amodφ(n))(bmodφ2(n))(modn),g^{a^b} \equiv g^{(a \mod{\varphi(n)})^{\scriptstyle(b \mod{\varphi^2(n)})}} \pmod{n},

where φ2(n)φ(φ(n)).\varphi^2(n) \triangleq \varphi(\varphi(n)).

§ Carmichael's Totient Function

We didn't talk about the Carmichael function in our MATH-470, however, this becomes useful in discussing the RSA algorithm.

Carmichael's Totient Function

Carmichael's totient uses the notation λ(n)\lambda(n), and is defined to be the smallest positive integer mm satisfying

am1(modn),a^{m} \equiv 1 \pmod{n},

for all a[1n)a \in [1\dots n) such that (a,n)=1(a, n) = 1.

§ Computing the Carmichael Function

Using results from Carmichael's theorem, we can find that λ(n)\lambda(n) can be computed in terms of Euler's totient function.

λ(pr)={φ(pr)if pP,or p=412φ(pr)if p=2 and r3\lambda\left(p^r\right) = \begin{cases} \varphi\left(p^r\right) & \text{if } p \in \mathbb{P}, \text{or } p = 4\\ \frac{1}{2}\varphi\left(p^r\right) & \text{if } p = 2 \text{ and } r \geq 3 \end{cases}