On the Subject of Cruel Modulo

Remember that super easy mathematical module? Here’s his evil twin.

  • This modulo shows three numbers, a keypad, and a small screen at the bottom which will display the answer.
  • Take the larger central number (n), raise it to the power of the smaller number in the top right (p), and then modulo this result by the smaller number in the top left (m).
  • To perform the modulo operation, multiply n by itself p times, then take this number subtract m from it repeatedly until it is less than m.
  • Alternatively, divide n^p by m and take the remainder.
  • Whichever method you prefer to use, once you have calculated the correct answer, enter it into the keypad and press the green submit button. The module will only process if at least a digit is inputted.
  • To clear your answer, press the red clear button.
  • Entering the correct answer will disarm the module. Entering an incorrect answer will cause a strike and reset both m and n, but NOT p.

The Square and Multiply method is explained here:

  1. Take n, modulo m, and call this x.
  2. Convert p into binary. (For example: 22 = 10110) For those not familiar to converting decimal to binary:
    1. Starting with the current value, divide this value by 2, and note its remainder. Repeat this step until the quotient is 0.
    2. Reverse the order of the remainders obtained, with the last remainder obtained being first, 2nd to last being second, and so on. This is your result in binary.
  3. Starting at 1 for the result, repeat the following procedure, while moduloing the result by m, until all binary digits are used up from p:
    1. Square this number, and move the pointer to the next digit. If this is the first action, start on the left-most binary digit.
    2. If the current binary digit is a 1, multiply this by x.