Note that in every pass through step 3, the equation holds true. When step 3 has been executed times, then, contains the answer that was sought. In summary, this algorithm basically counts up by ones until reaches , doing a multiply by and a modulo operation each time it adds one (to ensure the results stay small).
