Modular Arithmetic
Learn Modular Arithmetic (Foundations, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Modular Arithmetic Modular arithmetic works with remainders: a % m is the remainder after dividing by m. Results of counting problems get huge, so contests ask for the answer modulo 10 9 +7 . Useful rules: (a + b) % m = ((a % m) + (b % m)) % m and the same for multiplication, so you can reduce at every step and avoid overflow.