{
  "aliases": null,
  "backlinks": [
    {
      "field": "uses",
      "target": "0D3PFXEAKF"
    },
    {
      "field": "uses",
      "target": "0PMY0YQYXX"
    }
  ],
  "body": "\n## Summary\n\nThe Euclidean algorithm computes the [[greatest common divisor|02WF878BH1]] of two natural numbers $a$ and $b$.\nIt uses two rules: $\\gcd(a, 0) = a$, and $\\gcd(a, b) = \\gcd(b, a \\bmod b)$ when $b \\neq 0$.\nIt applies the second rule until the second number is $0$. Then the first number is the result.\nThe algorithm stops, because the second number gets smaller at each step.\n\n## Remarks\n\nThe second rule is true because $a$ and $b$ have the same common divisors as $b$ and $a \\bmod b$.\nThe number of steps is at most a constant times the number of digits of the smaller input. Lamé's theorem gives this bound.\nThe algorithm also works in each Euclidean domain, for example in the ring of polynomials over a field.\n\n## Explanations\n\n### L1 human\n\nTo find $\\gcd(48, 18)$, divide again and again, and keep the divisor and the remainder.\n$48 = 2 \\cdot 18 + 12$, then $18 = 1 \\cdot 12 + 6$, then $12 = 2 \\cdot 6 + 0$.\nThe last nonzero remainder is $6$, so $\\gcd(48, 18) = 6$.\n",
  "commit": "f591989ed15704e9d8755a7a5a6426d73de7a3ae",
  "front": {
    "kind": "concept",
    "msc": [
      "11A05"
    ],
    "name": "Euclidean algorithm",
    "same_as": {
      "wikidata": "Q230848",
      "wikipedia": "Euclidean algorithm"
    },
    "sources": [
      {
        "locator": "Procedure",
        "url": "https://en.wikipedia.org/wiki/Euclidean_algorithm"
      }
    ],
    "tag": "0TRNT4X7J0"
  },
  "kind": "concept",
  "link": "https://math2.tamnd.com/node/0TRNT4X7J0/",
  "links": null,
  "markdown": "https://math2.tamnd.com/node/0TRNT4X7J0.md",
  "msc": [
    "11A05"
  ],
  "name": "Euclidean algorithm",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/0TR/0TRNT4X7J0.md",
  "status": null,
  "tag": "0TRNT4X7J0",
  "uri": "m2://0TRNT4X7J0",
  "url": "https://math2.tamnd.com/wiki/euclidean-algorithm/",
  "writing": {
    "tag": "0TRNT4X7J0",
    "kind": "concept",
    "level": "W1",
    "next": [
      {
        "what": "edge defines in",
        "note": "at least one definition",
        "have": 0,
        "want": 1
      },
      {
        "what": "edge instance_of in",
        "note": "at least two examples",
        "have": 0,
        "want": 2
      },
      {
        "what": "edge not_instance_of in",
        "note": "at least one non-example",
        "have": 0,
        "want": 1
      },
      {
        "what": "edge specializes both",
        "note": "the more general notions and the special cases",
        "have": 0,
        "want": 1
      }
    ]
  }
}
