The Division Algorithm
Theorem Suppose that a and b are integers and a > 0. Then there exist unique integers r and q so that
- b = a*q + r
- 0 ≤ r < a
This is the reason that the mod operator % is well-defined. You find q and r this way.
- q = b//a
- r = b%a
Modular Arithmetic
Primality
An integer n ≥2 is prime if only divisor are 1 and itself.
Sorting