Question: (In python) Write a function modExp(x, y, n)that computes and returns the value of xymod n. Use the fast modular exponentiation algorithm given in Figure
(In python) Write a function modExp(x, y, n)that computes and returns the value of xymod n. Use the fast modular exponentiation algorithm given in Figure 9.7.4 of the zyBook.

Figure 9.7.4: An iterative algorithm for fast modular exponentiation. Input: Positive integers x and y. Output: x' mod n p:= 1 /p holds the partial result. s:= X /s holds the current z r=y /r is used to compute the binary expansion of y While (r> 0) If ( r mod 2= 1) p:= p's mod n S=Ss mod n = r div 2 End-while Return(p)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
