Calculator Shortcut for Modular Arithmetic
Modular arithmetic
If you think back to doing division with whole numbers, you may remember finding the whole number result and the remainder after division.Modulus
The modulus[footnote]Sometimes, instead of seeing 17 mod 5 = 2, you’ll see 17 ≡ 2 (mod 5). The ≡ symbol means “congruent to” and means that 17 and 2 are equivalent, after you consider the modulus 5.[/footnote] is another name for the remainder after division. For example, 17 mod 5 = 2, since if we divide 17 by 5, we get 3 with remainder 2.Example 1
Compute the following:- 10 mod 3
- 15 mod 5
- 27 mod 5
Answers
- Since 10 divided by 3 is 3 with remainder 1, 10 mod 3 = 1
- Since 15 divided by 5 is 3 with no remainder, 15 mod 5 = 0
- 27 = 128. 128 divide by 5 is 25 with remainder 3, so 27 mod 5 = 3
Try it Now
Compute the following:- 23 mod 7
- 15 mod 7
- 2034 mod 7
Modulus on a Standard Calculator
To calculate a mod n on a standard calculator- Divide a by n
- Subtract the whole part of the resulting quantity
- Multiply by n to obtain the modulus
Example 2
Calculate 31345 mod 419.Answer
| [latex]31345\div{419}=74.8090692[/latex] | Now subtract 74 to get just the decimal remainder |
| [latex]74.8090692-74=0.8090692[/latex] | Multiply this by 419 to get the modulus |
| [latex]0.8090692\times{419}=339[/latex] | This tells us 0.8090692 was equivalent to [latex]\frac{339}{419}[/latex] |