Perform modular operations and solve number theory problems
Modular arithmetic is a system of arithmetic for integers where numbers "wrap around" when reaching a certain value called the modulus.
In modular arithmetic, we perform operations and then find the remainder when divided by the modulus.
Computing a^b mod m efficiently using the square-and-multiply algorithm.
This is particularly useful in cryptography and number theory applications.
The modular inverse of a modulo m is a number x such that a×x ≡ 1 (mod m).
The inverse exists if and only if gcd(a, m) = 1.
A linear congruence is an equation of the form ax ≡ b (mod m).
Solutions exist if and only if gcd(a, m) divides b.