Home

[This page is auto-generated; please prefer to read the article’s PDF Form.]



[Prev]   [Up]   [Next]   

Exponentiation vs Modular Exponentiation

All the algorithms and their C methods presented below will apply both to exponentiation and modular-exponentiation, with slight changes. The methods are shown for modular-exponentiation and so contain many uses of modulo n operation done via “% n”, to reduce the multiplication results modulo n. Removing these “% n” occurrences will give us the methods for normal exponentiation.

This close similarity between the algorithms for these two exponentiations can be proven using the following relation from Modular Arithmetic. Here, x, y and n are any positive integers:

(xy) mod n = ((x mod n)(y mod n)) mod n

[Prev]   [Up]   [Next]