How does the mod work?

The modulo operation (abbreviated “mod”, or “%” in many programming languages) is the remainder when dividing . For example, “5 mod 3 = 2” which means 2 is the remainder when you divide 5 by 3.