This fact , together with Lagrange 's theorem , provides a proof for Euler 's theorem . This fact , together with Lagrange 's theorem on the possible sizes of subgroups of a group , provides a proof for Euler 's theorem that for all a coprime to n. The totient function also plays a key role in the definition of the RSA encryption system .