{
  "id": "eulers-theorem-number-theory",
  "title": "Euler’s Theorem (Number Theory)",
  "lang": "en",
  "source_lang": "en",
  "summary": "Euler’s theorem states that if an integer a is coprime to a positive integer n, then a raised to Euler’s totient of n is congruent to 1 modulo n.",
  "category": "mathematics",
  "subcategory": "algebra",
  "type": "concept",
  "aliases": [
    "Euler’s totient theorem",
    "Euler–Fermat theorem"
  ],
  "generated_at": "2026-11-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/eulers-theorem-number-theory/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/eulers-theorem-number-theory/",
      "json": "https://aiwiki.page/zh/eulers-theorem-number-theory.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "Euler’s theorem is a fundamental result in number theory describing powers of integers in modular arithmetic. It states that if \\(n\\geq 2\\) is an integer and \\(a\\) is an integer coprime to \\(n\\), then\n\n\\[a^{\\varphi(n)}\\equiv 1\\pmod n,\\]\n\nwhere \\(\\varphi(n)\\) is Euler’s totient function, the number of integers from \\(1\\) to \\(n\\) that are coprime to \\(n\\). Named after Leonhard Euler, the theorem generalizes Fermat’s little theorem and provides a basis for reducing large exponents, calculating modular inverses, and understanding the algebra behind RSA cryptography."
    },
    {
      "heading": "Statement and terminology",
      "text": "Two integers are coprime when their greatest common divisor is \\(1\\). Thus the hypothesis of Euler’s theorem is\n\n\\[\\gcd(a,n)=1.\\]\n\nThe conclusion \\(a^{\\varphi(n)}\\equiv 1\\pmod n\\) means that \\(n\\) divides \\(a^{\\varphi(n)}-1\\). Equivalently, \\(a^{\\varphi(n)}\\) leaves remainder \\(1\\) upon division by \\(n\\).\n\nThe totient function is defined by\n\n\\[\\varphi(n)= \\#\\{k:1\\leq k\\leq n,\\ \\gcd(k,n)=1\\}.\\]\n\nIf the distinct prime divisors of \\(n\\) are \\(p_1,\\ldots,p_r\\), then\n\n\\[\\varphi(n)=n\\prod_{i=1}^{r}\\left(1-\\frac{1}{p_i}\\right).\\]\n\nIn particular, for a prime \\(p\\) and an integer \\(k\\geq 1\\),\n\n\\[\\varphi(p)=p-1, \\qquad \\varphi(p^k)=p^{k-1}(p-1).\\]\n\nFor example, the integers between \\(1\\) and \\(10\\) coprime to \\(10\\) are \\(1,3,7,9\\), so \\(\\varphi(10)=4\\). Since \\(3\\) is coprime to \\(10\\), Euler’s theorem gives\n\n\\[3^4=81\\equiv 1\\pmod {10}.\\]\n\nThe restriction to coprime integers is essential. If \\(\\gcd(a,n)>1\\), a prime dividing both \\(a\\) and \\(n\\) divides every positive power of \\(a\\), so no such power can be congruent to \\(1\\) modulo \\(n\\)."
    },
    {
      "heading": "Elementary proof",
      "text": "A reduced residue system modulo \\(n\\) consists of one representative of each congruence class coprime to \\(n\\). Write such a system as\n\n\\[r_1,r_2,\\ldots,r_{\\varphi(n)}.\\]\n\nIf \\(\\gcd(a,n)=1\\), multiplication by \\(a\\) rearranges these classes. Indeed, each \\(ar_i\\) remains coprime to \\(n\\), and\n\n\\[ar_i\\equiv ar_j\\pmod n\\]\n\nimplies\n\n\\[r_i\\equiv r_j\\pmod n,\\]\n\nbecause a factor coprime to the modulus can be cancelled. Thus multiplication by \\(a\\) induces a permutation of the reduced residue classes.\n\nConsequently, their products satisfy\n\n\\[(ar_1)(ar_2)\\cdots(ar_{\\varphi(n)}) \\equiv r_1r_2\\cdots r_{\\varphi(n)} \\pmod n.\\]\n\nFactoring out the powers of \\(a\\) yields\n\n\\[a^{\\varphi(n)}r_1r_2\\cdots r_{\\varphi(n)} \\equiv r_1r_2\\cdots r_{\\varphi(n)} \\pmod n.\\]\n\nThe product \\(r_1r_2\\cdots r_{\\varphi(n)}\\) is coprime to \\(n\\), so it too can be cancelled. The result is\n\n\\[a^{\\varphi(n)}\\equiv 1\\pmod n.\\]\n\nCancellation here depends on coprimality, not merely on the cancelled factor being nonzero. This distinction is crucial for composite moduli."
    },
    {
      "heading": "Group-theoretic interpretation",
      "text": "In group theory, the invertible residue classes modulo \\(n\\) form a group under multiplication, denoted\n\n\\[(\\mathbb Z/n\\mathbb Z)^\\times.\\]\n\nIt is the group of units of the ring \\(\\mathbb Z/n\\mathbb Z\\), and it has exactly \\(\\varphi(n)\\) elements.\n\nLagrange’s theorem implies that the order of an element of a finite group divides the number of elements in the group. Therefore, raising any element of \\((\\mathbb Z/n\\mathbb Z)^\\times\\) to the power \\(\\varphi(n)\\) gives the identity element. This is precisely Euler’s theorem.\n\nMore specifically, the multiplicative order of \\(a\\) modulo \\(n\\), written \\(\\operatorname{ord}_n(a)\\), is the smallest positive integer \\(d\\) such that\n\n\\[a^d\\equiv 1\\pmod n.\\]\n\nFor \\(\\gcd(a,n)=1\\),\n\n\\[\\operatorname{ord}_n(a)\\mid\\varphi(n).\\]\n\nEuler’s theorem therefore supplies a universal exponent for all invertible classes, but not necessarily the smallest exponent for a particular class."
    },
    {
      "heading": "Relationship to Fermat’s little theorem",
      "text": "For a prime modulus \\(p\\), every nonzero residue class is invertible and \\(\\varphi(p)=p-1\\). Euler’s theorem becomes\n\n\\[a^{p-1}\\equiv 1\\pmod p \\qquad\\text{if }p\\nmid a,\\]\n\nwhich is Fermat’s little theorem.\n\nThe equivalent prime-modulus statement\n\n\\[a^p\\equiv a\\pmod p\\]\n\nholds for every integer \\(a\\), including multiples of \\(p\\).\n\nEuler’s contribution extended the prime-modulus result to arbitrary positive moduli by replacing \\(p-1\\) with \\(\\varphi(n)\\) and requiring coprimality. The theorem belongs to Euler’s eighteenth-century development of number theory; its modern group-theoretic formulation places it within a more general theory of finite groups."
    },
    {
      "heading": "Applications",
      "text": "Reducing large exponents\n\nIf \\(\\gcd(a,n)=1\\), write a nonnegative exponent \\(m\\) as\n\n\\[m=q\\varphi(n)+r, \\qquad 0\\leq r<\\varphi(n).\\]\n\nThen\n\n\\[a^m =\\left(a^{\\varphi(n)}\\right)^q a^r \\equiv a^r\\pmod n.\\]\n\nFor example, \\(\\varphi(20)=8\\) and \\(\\gcd(7,20)=1\\). Since\n\n\\[123\\equiv 3\\pmod 8,\\]\n\nit follows that\n\n\\[7^{123}\\equiv 7^3=343\\equiv 3\\pmod {20}.\\]\n\nReducing exponents modulo \\(\\varphi(n)\\) in this way is not generally valid for bases that are not coprime to \\(n\\).\n\nComputing modular inverses\n\nA modular multiplicative inverse of \\(a\\) modulo \\(n\\) is an integer \\(b\\) satisfying\n\n\\[ab\\equiv 1\\pmod n.\\]\n\nSuch an inverse exists exactly when \\(\\gcd(a,n)=1\\). Euler’s theorem gives\n\n\\[a^{-1}\\equiv a^{\\varphi(n)-1}\\pmod n.\\]\n\nFor instance, because \\(\\varphi(10)=4\\),\n\n\\[3^{-1}\\equiv 3^3=27\\equiv 7\\pmod {10}.\\]\n\nThis formula is useful theoretically and when the totient is known. The extended Euclidean algorithm also computes modular inverses and does not require knowing \\(\\varphi(n)\\).\n\nRSA cryptography\n\nEuler’s theorem is central to the mathematical explanation of RSA. For distinct primes \\(p\\) and \\(q\\), let\n\n\\[n=pq, \\qquad \\varphi(n)=(p-1)(q-1).\\]\n\nIf positive integers \\(e\\) and \\(d\\) satisfy\n\n\\[ed\\equiv 1\\pmod{\\varphi(n)},\\]\n\nthen, for every message representative \\(m\\) coprime to \\(n\\),\n\n\\[(m^e)^d=m^{ed}\\equiv m\\pmod n.\\]\n\nRSA correctness also holds for message representatives not coprime to \\(n\\), but Euler’s theorem alone does not establish that case. Applying Fermat’s little theorem separately modulo \\(p\\) and modulo \\(q\\), then using the Chinese remainder theorem, establishes the result for every residue class modulo \\(n\\).\n\nThis algebraic correctness is distinct from cryptographic security; a secure encryption scheme requires additional constructions beyond raw modular exponentiation."
    },
    {
      "heading": "Sharper exponents and limitations",
      "text": "The Carmichael function \\(\\lambda(n)\\) is the smallest positive integer such that\n\n\\[a^{\\lambda(n)}\\equiv 1\\pmod n\\]\n\nfor every integer \\(a\\) coprime to \\(n\\). It satisfies\n\n\\[\\lambda(n)\\mid\\varphi(n).\\]\n\nThus it can provide a smaller universal exponent than Euler’s totient.\n\nFor example,\n\n\\[\\varphi(8)=4, \\qquad \\lambda(8)=2.\\]\n\nEvery odd integer satisfies \\(a^2\\equiv 1\\pmod 8\\), so the exponent \\(4\\) supplied by Euler’s theorem is valid but not minimal. For a particular base, the multiplicative order can be smaller still.\n\nEuler’s theorem is also not a primality criterion: its conclusion holds for every modulus when its hypotheses are satisfied and the correct totient is used. By contrast, the congruence \\(a^{n-1}\\equiv 1\\pmod n\\), used in Fermat-style primality testing, may hold even when \\(n\\) is composite.\n\nFinally, the theorem does not itself supply an efficient way to calculate \\(\\varphi(n)\\) for an arbitrary large integer. The product formula is straightforward when the prime factorization is known, but obtaining that factorization may be computationally difficult. For an RSA modulus \\(n=pq\\), knowledge of \\(\\varphi(n)\\) reveals\n\n\\[p+q=n+1-\\varphi(n),\\]\n\nso \\(p\\) and \\(q\\) can be recovered as the roots of\n\n\\[x^2-\\bigl(n+1-\\varphi(n)\\bigr)x+n=0.\\]"
    }
  ],
  "links": [
    "number-theory",
    "modular-arithmetic",
    "eulers-totient-function",
    "leonhard-euler",
    "fermats-little-theorem",
    "greatest-common-divisor",
    "prime-number",
    "permutation",
    "group-theory",
    "ring-mathematics",
    "lagranges-theorem-group-theory",
    "modular-multiplicative-inverse",
    "euclidean-algorithm",
    "rsa-cryptosystem",
    "chinese-remainder-theorem"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}