{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Proof\n\n1. Let $p$ be an odd prime, $a$ an integer with $p \\nmid a$, and $h = (p-1)/2$. For $k = 1, \\dots, h$, let $r_k$ be the least positive residue of $ka$ modulo $p$.\n2. By [[Euclid's lemma|051VYKA1EX]], $p \\nmid ka$, so $1 \\le r_k \\le p - 1$. Since $p$ is odd, $r_k \\ne p/2$.\n3. Put $s_k = r_k$ and $\\varepsilon_k = 1$ if $r_k \u003c p/2$. Put $s_k = p - r_k$ and $\\varepsilon_k = -1$ if $r_k \u003e p/2$.\n4. Then $1 \\le s_k \\le h$ and $ka \\equiv \\varepsilon_k s_k \\pmod p$. Exactly $n$ of the $\\varepsilon_k$ equal $-1$, where $n$ is the number in the statement.\n5. The $s_k$ are distinct. Suppose $s_k = s_l$ with $1 \\le k, l \\le h$. Then $ka \\equiv \\pm la$, so $p \\mid (k \\mp l) a$. As $p \\nmid a$, Euclid's lemma gives $p \\mid k - l$ or $p \\mid k + l$.\n6. But $\\abs{k - l} \u003c p$ and $2 \\le k + l \\le p - 1$. So $k + l$ is not a multiple of $p$, and $k - l = 0$.\n7. So $s_1, \\dots, s_h$ are $h$ distinct numbers in $\\set{1, \\dots, h}$. Hence they are $1, \\dots, h$ in some order.\n8. Multiplying the congruences of step 4 with [[products of congruences|072D5G4SK6]] gives $a^h \\cdot h! = \\prod_{k=1}^{h} ka \\equiv \\prod_{k=1}^{h} \\varepsilon_k s_k = (-1)^n h! \\pmod p$.\n9. So $p \\mid h! \\left(a^h - (-1)^n\\right)$. Every factor of $h!$ is less than $p$, so $p \\nmid h!$ by Euclid's lemma. Thus $a^h \\equiv (-1)^n \\pmod p$.\n10. By [[Euler's criterion|0M7DEDKSYB]], $\\left(\\frac{a}{p}\\right) \\equiv a^h \\equiv (-1)^n \\pmod p$.\n11. Since $p \\nmid a$, the [[Legendre symbol|01J8AMV9RS]] is $\\pm 1$. Two signs that agree modulo $p \\ge 3$ are equal. So $\\left(\\frac{a}{p}\\right) = (-1)^n$.\n\n## Idea\n\nFold each residue of $ka$ into the range $1, \\dots, h$ by replacing $r$ with $p - r$ when $r \u003e p/2$. The folded numbers are exactly $1, \\dots, h$, so the product of the $ka$ is $h!$ up to the sign $(-1)^n$. Comparing with $a^h h!$ and using Euler's criterion gives the lemma.\n",
  "commit": "68a8c3dc73fd55004b2796431c607c30960d1a85",
  "front": {
    "kind": "proof",
    "msc": [
      "11A15"
    ],
    "name": "Proof of Gauss's lemma on quadratic residues",
    "proves": "037ACYXB5Z",
    "sources": [
      {
        "locator": "Proof",
        "url": "https://en.wikipedia.org/wiki/Gauss%27s_lemma_(number_theory)"
      }
    ],
    "tag": "3HKZCMGESN",
    "uses": [
      "01J8AMV9RS",
      "0M7DEDKSYB",
      "051VYKA1EX",
      "072D5G4SK6",
      "0TPW25CBN6"
    ]
  },
  "kind": "proof",
  "link": "https://math2.tamnd.com/node/3HKZCMGESN/",
  "links": [
    {
      "field": "proves",
      "target": "037ACYXB5Z"
    },
    {
      "field": "uses",
      "target": "01J8AMV9RS"
    },
    {
      "field": "uses",
      "target": "0M7DEDKSYB"
    },
    {
      "field": "uses",
      "target": "051VYKA1EX"
    },
    {
      "field": "uses",
      "target": "072D5G4SK6"
    },
    {
      "field": "uses",
      "target": "0TPW25CBN6"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/3HKZCMGESN.md",
  "msc": [
    "11A15"
  ],
  "name": "Proof of Gauss's lemma on quadratic residues",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/3HK/3HKZCMGESN.md",
  "status": null,
  "tag": "3HKZCMGESN",
  "uri": "m2://3HKZCMGESN",
  "url": "https://math2.tamnd.com/wiki/proof-of-gausss-lemma-on-quadratic-residues/",
  "writing": {
    "tag": "3HKZCMGESN",
    "kind": "proof",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      }
    ]
  }
}
