# Modular Numbers and Cryptography

 Properties of addition in modular arithmetic: If $$a + b = c$$, then $$a \pmod{N} + b \pmod{N} \equiv c \pmod{N}$$. If $$a \equiv b \pmod{N}$$, then $$a + k \equiv b + k \pmod{N}$$ for any integer $$k$$. If $$a \equiv b \pmod{N}$$, and $$c \equiv d \pmod{N}$$, then $$a + c \equiv b + d \pmod{N}$$. If $$a \equiv b \pmod{N}$$, then $$-a \equiv -b \pmod{N}$$.

### Examples

1. Find the residue of $$(9+7) \pmod{5}$$

One method is to find each residue and add them together.

\begin{align} 9 &\pmod{5} + 7 \pmod{5} \\ \equiv 4 &\pmod{5} + 2 \pmod{5} \\ \equiv 6 &\pmod{5} \\ \equiv 1 &\pmod{5} \end{align}

However, based on the first property above, we can perform the operation quicker if we add first.

\begin{align} &(9+7) \pmod{5} \\ \equiv &16 \pmod{5} \\  \equiv &1 \pmod{5} \end{align}

2. Find the residue of $$(81 +38 +72 +64) \pmod{11}$$

\begin{align} &\equiv  255 \pmod{11} \\ &\equiv 2 \pmod{11} \end{align}

3. Perform the operation $$(72 - 18) \pmod{13}$$

The same method can be applied to subtraction because it is simply an addition of a negative integer.

\begin{align} &\equiv  54\pmod{13} \\ &\equiv 2 \pmod{13} \end{align}

4. Perform the operation $$(23 - 77 + 32) \pmod{9}$$

\begin{align} &\equiv  -22\pmod{9} \\ &\equiv 5 \pmod{9} \end{align}