0% found this document useful (0 votes)
22 views

Css Exp 1

Uploaded by

ritzinator24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Css Exp 1

Uploaded by

ritzinator24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

EXPERIMENT 1

Aim: To implement Extended Euclidean algorithm

CODE:

def gcdExtended(a, b):


# Base Case
if a == 0:
return b, 0, 1
gcd, x1, y1 = gcdExtended(b % a, a)
#Update x and y using results of recursive call
x = y1 - (b//a) * x1
y = x1
return gcd, x, y

a = int(input("Enter the first number: "))


b = int(input("Enter the second number: "))
g, x, y = gcdExtended(a, b)
print("GCD of",a,"and",b, "is",g)

OUTPUT:

Enter the first number: 50


Enter the second number: 35
GCD of 50 and 35 is 5

You might also like