Using the calculator
Type two whole numbers, such as 17 mod 5 or just 17, 5. The remainder appears as you type, with the quotient and a check line.
The numbers can be as long as you like. Everything is worked in exact whole-number arithmetic, so a 30-digit number mod 97 is exact.
What mod means
a mod n is the remainder when a is divided by n. 17 ÷ 5 is 3 with 2 left over, so 17 mod 5 = 2.
A clock is the everyday example. Four hours after 9 o'clock it's 1 o'clock, because 13 mod 12 = 1. Carl Friedrich Gauss set out this arithmetic of remainders in his Disquisitiones Arithmeticae of 1801.
Negative numbers: two answers
For −7 mod 3, maths and Python say 2, because the remainder takes the sign of the divisor. JavaScript, C and Java say −1, because their % operator keeps the sign of the first number, the one being divided, whatever the divisor is.
Both are valid, since −7 = −3 × 3 + 2 and −7 = −2 × 3 − 1. The Negative numbers setting switches between them, and the other answer is shown as a row. Excel's MOD function follows the divisor, like Python.
Questions
What is 10 mod 3?
It's 1.
What is a mod n when a is smaller than n?
a itself.
Can I mod by 0?
No. Division by 0 has no answer, so there's no remainder either, and the calculator says so rather than guessing.
Sources
Added and reviewed . What's new
