Content deleted Content added
No edit summary |
No edit summary |
||
Line 1:
We define a ≡ b (mod c) if (a - b)/c is an integer. The function w = f(x, y, z) ≡ x<sup>y</sup> (mod z) can be computed efficiently, even when x, y, z > 10<sup>300</sup> by the following recursive algorithm (we assume that the integers x > 0, y > -1, and z > 0):
#if y = 0, return 1.
#if y is even, put u = f(x, y/2, z) and return (u*u) mod z
#return {x*f(x, y - 1, z}} mod z
*'''Analysis'''
*The numbers computed are always less than z<sup>2</sup>, and the final answer is less than z.
|