{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Proof\n\n1. Let $p$ be a [[prime number|0SN0MAEKYX]] and $n$ a natural number. If $n = 0$, then $0! = 1$ by the definition of the [[factorial|0WFCGVMRRC]]. So $\\nu_p(0!) = 0$, and every term $\\lfloor 0 / p^i \\rfloor$ is $0$. Assume now $n \\ge 1$.\n2. We have $n! = 1 \\cdot 2 \\cdots n$. Applying the [[valuation of a product|0850JJMJYZ]] $n - 1$ times gives $\\nu_p(n!) = \\sum_{k=1}^{n} \\nu_p(k)$.\n3. Let $1 \\le k \\le n$ and $i \\ge 1$. By the definition of the [[p-adic valuation|04VCPS30ZE]], $p^i \\mid k$ holds if and only if $i \\le \\nu_p(k)$. Indeed, if $i \\le \\nu_p(k)$ then $p^i \\mid p^{\\nu_p(k)} \\mid k$, and if $i \u003e \\nu_p(k)$ then $p^i \\nmid k$ by maximality.\n4. So $\\nu_p(k)$ is the number of integers $i \\ge 1$ with $p^i \\mid k$.\n5. Substituting step 4 into step 2 and counting the pairs $(k, i)$ the other way gives $\\nu_p(n!) = \\sum_{i \\ge 1} N_i$. Here $N_i$ is the number of $k$ with $1 \\le k \\le n$ and $p^i \\mid k$.\n6. Only finitely many $N_i$ are nonzero, because $p^i \u003e n$ implies $N_i = 0$.\n7. Fix $i \\ge 1$ and let $d = p^i$. The multiples of $d$ in $\\set{1, \\dots, n}$ are the numbers $jd$ with $j$ an integer and $1 \\le j \\le n/d$.\n8. An integer $j$ satisfies $j \\le n/d$ if and only if $j \\le \\lfloor n/d \\rfloor$, by the definition of the [[floor function|0YVRNEDSVG]]. So $N_i = \\lfloor n / p^i \\rfloor$.\n9. Hence $\\nu_p(n!) = \\sum_{i=1}^{\\infty} \\lfloor n / p^i \\rfloor$, where only finitely many terms are nonzero.\n\n## Idea\n\nEach $k \\le n$ contributes $\\nu_p(k)$ factors of $p$ to $n!$. Count these factors by layers: every multiple of $p$ gives one, every multiple of $p^2$ gives one more, and so on. The number of multiples of $p^i$ up to $n$ is $\\lfloor n/p^i \\rfloor$.\n",
  "commit": "4a3290d299c8b2cd6493fce2296920ba7f82d942",
  "front": {
    "kind": "proof",
    "msc": [
      "11A51"
    ],
    "name": "Proof of Legendre's formula by counting multiples of prime powers",
    "proves": "01WPV9PHN7",
    "sources": [
      {
        "locator": "Proof",
        "url": "https://en.wikipedia.org/wiki/Legendre%27s_formula"
      }
    ],
    "tag": "WFYM20H4MK",
    "uses": [
      "04VCPS30ZE",
      "0850JJMJYZ",
      "0WFCGVMRRC",
      "0YVRNEDSVG",
      "0SN0MAEKYX"
    ]
  },
  "kind": "proof",
  "link": "https://math2.tamnd.com/node/WFYM20H4MK/",
  "links": [
    {
      "field": "proves",
      "target": "01WPV9PHN7"
    },
    {
      "field": "uses",
      "target": "04VCPS30ZE"
    },
    {
      "field": "uses",
      "target": "0850JJMJYZ"
    },
    {
      "field": "uses",
      "target": "0WFCGVMRRC"
    },
    {
      "field": "uses",
      "target": "0YVRNEDSVG"
    },
    {
      "field": "uses",
      "target": "0SN0MAEKYX"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/WFYM20H4MK.md",
  "msc": [
    "11A51"
  ],
  "name": "Proof of Legendre's formula by counting multiples of prime powers",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/WFY/WFYM20H4MK.md",
  "status": null,
  "tag": "WFYM20H4MK",
  "uri": "m2://WFYM20H4MK",
  "url": "https://math2.tamnd.com/wiki/proof-of-legendres-formula-by-counting-multiples-of-prime-powers/",
  "writing": {
    "tag": "WFYM20H4MK",
    "kind": "proof",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      }
    ]
  }
}
