The modulo operation can be achieved using subtraction. As long as the upper number is bigger than the lower number, the lower one is subtracted from the upper one. The result of the subtraction replaces the upper value.

The solution has two main parts:

  1. The numbers are compared (green states). If the lower one is bigger than the upper one, the Turing Machine halts.
  2. The lower number is subtracted from the upper one (blue states) and the program starts over.