Question: PLEASE WRITE IN PYTHON Program a function mod_exp (b,n,m) that computes bnmodm using the algorithm discussed in lecture. No credit will be given to functions

PLEASE WRITE IN PYTHON

PLEASE WRITE IN PYTHON Program a function mod_exp (b,n,m) that computes bnmodm

using the algorithm discussed in lecture. No credit will be given to

Program a function mod_exp (b,n,m) that computes bnmodm using the algorithm discussed in lecture. No credit will be given to functions that employ any other implementation. For example, if the function implementation simply consists of bn%m, no credit will be given. The function should satisfy the following: 1. INPUT: - b - positive integer representing the base - n - positive integer representing the exponent - m - positive integer representing the modulo 1. OUTPUT: - the computation of bn mod m if b,n,m are positive integers, 0 otherwise. EXAMPLE: \[ \gg \text { mod_exp }(3,644,645) \] 36 def nod_exp (b,n,m) : \# FIDOHE: Implement this function pass PSEUDOCODE | Modular Exponentiation INPUT: b-integer, m-integer, n=(ak1,ak2,,a1,a0)2 OUTPUT: bn mod m Example 6. Truce throagh the algarithm to compate 311 mod 2 . in the expansion of n START: b=3n=11=(1011)2 HMTIAlize: x=1p=3mad2=1 FaR: i0:a0=2x=1.1mod2=1p=12mod2=1 i=1:a1==1TRA=1.1mod2=1 p=12mod2=1 i=2:a0==1malsep=12mod2=1 t=3:a3==1 TRuE x=11 mod 2= p=82mod2=1 returnx=1 8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!