a*b=x mod k code example Example 1: modulo subtraction ((a%c - b%c) % c + c) % c Example 2: modulo addition (A + B) mod C = (A mod C + B mod C) mod C