Question
please help my understand why this code is failing, below i will provide source code and picture of my error. if you can provide fixes
please help my understand why this code is failing, below i will provide source code and picture of my error. if you can provide fixes that would be greatly appreciated. project due very soon! thank you!
source code:
def powMod_sm(base, exp, n): exp_b=bin(exp) value=base for i in range(3, len(exp_b)): value=(value**2)%n if exp_b[i:i+1]=='1: ': value = (value * base)% n return value # using the euclidean Algorithm def computeGCD(x, y): while y: x, y = y, x % y return x #Extended euclidean Algorithm method to calculate gcd and get the coefficient def extendedGCD(a, b): if a == 0: return b, 0, 1 gcd, x1, y1 = extendedGCD(b % a, a) x = y1 - (b // a)* x1 y = x1 return gcd, x, y # calculating the modular inverse using EEA def mod_Inv(b, n): gcd, _, t = extendedGCD(n, b) if gcd==1: i = t % n elif gcd!=1: print("Inverse is undefined") return i #miller-rabin Primality test def mrt(p): if p == 2 or p == 3: return True if p
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started