Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 . Complete the Python script EuclideanAlgoShell.py that will implement the Euclidean Al - gorithm. Use this program in order to compute gcd ( a

1. Complete the Python script EuclideanAlgoShell.py that will implement the Euclidean Al-gorithm. Use this program in order to compute gcd(a, b) where a =1326 and b =374.
def euclidgcd(a,b):
while b!=0:
#fill in Python code here
return a
a =2322
b =654
g=euclidgcd(a,b)
print(g)
2. Complete the Python script ExtEuclideanAlgoShell.py that will implement the Extended Euclidean Algorithm.
def exteuclidgcd(a,b):
#Initialize variables
x1=0
x2=1
y1=1
y2=0
#loop to iteratively converge on the solution
while (b>0):
#fill in code here to complete this script
#reassign values
a=b
b=r
x2=x1
x1=x
y2=y1
y1=y
#print values at each iteration
print(q,r,x,y,a,b,x2,x1,y2,y1)
#set final answer and pass back to main by reference
gcd=a
x=x2
y=y2
return x,y,gcd
a=4864
b=3458
x,y,gcd=exteuclidgcd(a,b)
print(x,y,gcd)
Verify your code by
a. Running the Extended Euclidean Algorithm example provided in the lecture slides.
b. Determining x, y and gcd(a, b) such that gcd(a, b)= ax+by where a =6090 and b =2431.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago