Home /permanent

Modular Arithmetic

Modular Arithmetic is a system of arithmetic for integers where numbers "wrap around" after reaching a certain value, called the modulus.

The classic example is a 12-hour clock: 4 hours after 10 o'clock is 2 o'clock, so 10+4≡2(mod12)10 + 4 \equiv 2 \pmod{12}.

We say a≡b(modn)a \equiv b \pmod{n} ($a$ is congruent to bb modulo nn) if aa and bb have the same remainder when divided by nn.

It's the foundation for a lot of cryptography, including RSA. The Extended Euclidean Algorithm is used to find modular inverses.