Discrete exponential function

This is an old revision of this page, as edited by Garfield Garfield (talk | contribs) at 18:25, 30 September 2014. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

We define a ≡ b (mod c) if (a - b)/c is an integer. Define the function f(x, y, z) ≡ xy (mod z), such that f ∈ {0, 1, ... , z - 1}. Then w = f(x, y, z) can be computed efficiently, even when x, y, z > 10300 by the following recursive algorithm (we assume that the integers x > 0, y > -1, and z > 0):

  1. if y = 0, return 1.
  2. if y is even, put u = f(x, y/2, z) and return (u*u) mod z
  3. return {x*f(x, y - 1, z}} mod z
  • Analysis
  • The numbers computed are always less than z2, and the final answer is less than z.