Using the calculator
Type two numbers, such as 17 mod 5, 17 % 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. Decimals work too. For 5.5 mod 2, both numbers are scaled up by 10 first, so the answer is an exact 1.5.
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, math 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, as long as a is 0 or more. A negative a works differently. −3 mod 5 is 2, not −3.
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 . Last updated and reviewed . What's new
