I’ve already presented and proved the rule for modular addition, so for a sense of completeness, but mostly to satisfy my OCD, now I’ll cover the rule for modular subtraction. When doing subtraction in modular arithmetic, the rule is:
If we subtract integer from integer and calculate the difference modulo , we get the same answer as if we had subtracted modulo from modulo and then calculated that difference modulo . Like the modular addition rule, this rule can also be expanded to include multiple integers.
Proof
In order to prove that the two sides of the equations are equal to one another, we again redefine and using the quotient remainder theorem:
where this means that
where this means that
Starting with the left hand side of the equation, we have:
Eliminating multiples of since we are doing leaves us with:
The right hand side only requires a simple substitution and we’re done: