{
  "aliases": [
    "lucas-lehmer-primality-test"
  ],
  "backlinks": null,
  "body": "\n## Statement\n\nLet $p$ be an odd prime, and let $M_p = 2^p - 1$ be the [[Mersenne number|0GJBJ19NXR]].\nDefine the sequence $(s_i)_{i \\ge 0}$ by $s_0 = 4$ and $s_i = s_{i-1}^2 - 2$ for $i \\ge 1$.\nThen $M_p$ is prime if and only if $s_{p-2} \\equiv 0 \\pmod{M_p}$.\n\n## Remarks\n\nFor example, take $p = 5$ and $M_5 = 31$. Modulo $31$, the sequence is $4, 14, 8, 0$, so $s_3 \\equiv 0$ and $31$ is prime.\nIn practice, one reduces each term modulo $M_p$. Then the test needs $p - 2$ squarings of numbers with at most $p$ bits.\n\n## History\n\nÉdouard Lucas developed the test in 1878, and Derrick Henry Lehmer proved it in 1930.\n\n## Explanations\n\n### L1 human\n\nThe test checks a Mersenne number for primality with a simple loop: square, subtract $2$, and reduce modulo $M_p$.\nAfter $p - 2$ steps, the result is $0$ exactly when $M_p$ is prime.\n",
  "commit": "545acf83a9b75c8ddc375ef8b23d2ae101a4d7e4",
  "front": {
    "aliases": [
      "lucas-lehmer-primality-test"
    ],
    "kind": "statement",
    "msc": [
      "11Y11"
    ],
    "name": "Lucas–Lehmer test",
    "role": "theorem",
    "same_as": {
      "wikidata": "Q1138992",
      "wikipedia": "Lucas–Lehmer primality test"
    },
    "sources": [
      {
        "locator": "The test",
        "url": "https://en.wikipedia.org/wiki/Lucas%E2%80%93Lehmer_primality_test"
      }
    ],
    "tag": "061BTYA0RN",
    "uses": [
      "0GJBJ19NXR",
      "0TPW25CBN6"
    ]
  },
  "kind": "statement",
  "link": "https://math2.tamnd.com/node/061BTYA0RN/",
  "links": [
    {
      "field": "uses",
      "target": "0GJBJ19NXR"
    },
    {
      "field": "uses",
      "target": "0TPW25CBN6"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/061BTYA0RN.md",
  "msc": [
    "11Y11"
  ],
  "name": "Lucas–Lehmer test",
  "prov": null,
  "role": "theorem",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/061/061BTYA0RN.md",
  "status": null,
  "tag": "061BTYA0RN",
  "uri": "m2://061BTYA0RN",
  "url": "https://math2.tamnd.com/wiki/lucas-lehmer-test/",
  "writing": {
    "tag": "061BTYA0RN",
    "kind": "statement",
    "level": "W1",
    "next": [
      {
        "what": "edge about out",
        "note": "the concepts that the statement is about",
        "have": 0,
        "want": 1
      },
      {
        "what": "edge proves in",
        "note": "at least one proof node",
        "have": 0,
        "want": 1
      },
      {
        "what": "edge instance_of or illustrates in",
        "note": "one example that shows the statement at work",
        "have": 0,
        "want": 1
      },
      {
        "what": "explanation L2",
        "have": 0,
        "want": 1
      }
    ]
  }
}
