{
  "aliases": [
    "mod",
    "remainder"
  ],
  "backlinks": null,
  "body": "\n## Definition\n\nLet $a$ and $n$ be integers with $n \\neq 0$.\nThe integer $a \\bmod n$ is the remainder $r$ of the [[division of $a$ by $n$|0CHQKZFK5S]].\nThus $a \\bmod n$ is the unique integer $r$ such that $0 \\le r \u003c |n|$ and $a - r$ is a multiple of $n$.\n\n## Remarks\n\nFor example, $17 \\bmod 5 = 2$ and $(-17) \\bmod 5 = 3$.\nMany programming languages use a different convention. In them, the remainder has the sign of $a$, so the result for $-17$ and $5$ is $-2$.\nThe Lean library Mathlib sets $a \\bmod 0 = a$.\n\n## Explanations\n\n### L1 human\n\nThe value $a \\bmod n$ is what is left after you take away from $a$ as many copies of $n$ as you can.\nA clock uses this operation: $15$ hours after $0$ o'clock, a $12$-hour clock shows $15 \\bmod 12 = 3$.\n",
  "commit": "545acf83a9b75c8ddc375ef8b23d2ae101a4d7e4",
  "front": {
    "aliases": [
      "mod",
      "remainder"
    ],
    "defines": "03BR7SAX0Q",
    "kind": "definition",
    "msc": [
      "11A07"
    ],
    "name": "Modulo operation",
    "sources": [
      {
        "locator": "Variants of the definition",
        "url": "https://en.wikipedia.org/wiki/Modulo"
      }
    ],
    "tag": "04FHQSJCQ5",
    "uses": [
      "0CHQKZFK5S"
    ]
  },
  "kind": "definition",
  "link": "https://math2.tamnd.com/node/04FHQSJCQ5/",
  "links": [
    {
      "field": "defines",
      "target": "03BR7SAX0Q"
    },
    {
      "field": "uses",
      "target": "0CHQKZFK5S"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/04FHQSJCQ5.md",
  "msc": [
    "11A07"
  ],
  "name": "Modulo operation",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/04F/04FHQSJCQ5.md",
  "status": null,
  "tag": "04FHQSJCQ5",
  "uri": "m2://04FHQSJCQ5",
  "url": "https://math2.tamnd.com/wiki/modulo-operation-definition/",
  "writing": {
    "tag": "04FHQSJCQ5",
    "kind": "definition",
    "level": "W1",
    "next": [
      {
        "what": "edge instance_of in",
        "note": "one example",
        "have": 0,
        "want": 1
      },
      {
        "what": "edge not_instance_of in",
        "note": "one non-example that fails one clause",
        "have": 0,
        "want": 1
      }
    ]
  }
}
