Question: 1. Implement the function Fast Modular Exponentiation (b, k, m) which computes b mod m using only around 2k modular multiplications. You are not

1. Implement the function Fast Modular Exponentiation (b, k, m) which computes b mod m using only around 2k modular multiplications. You are not allowed to use Python built-in exponentiation functions. 3 1 2 3 4 5 6 7 11 9 def FastModular Exponentiation (b, k, m): result = 1 base = ba whilek > 01 if kN 2 11 (result = base) & m base (base base) #Square the base and reduce modulo m k // 2# Divide k by 2 (right shift). return result result 10 11 12 13 bw3 14 k=13 15 MW7 16 result FastModularExponentiation(b, k, mi 17 print (result) 18 X Incorrect Expected result: 1533797728, got 1996638295 instead Try again! Run Reset 0/1 point
Step by Step Solution
There are 3 Steps involved in it
A python def FastModularExponentiationb k m result 1 base b m while k 0 if k 2 1 result result ... View full answer
Get step-by-step solutions from verified subject matter experts
