the art of
Algorithm
Notes on Analysis and Design



Euclid(Computing GCD) Algorithm

Following is a python program for computing gcd of two numbers using euclid algorithm

1
2
3
4
5
6
7
8
9
10
11
12
#Euclid algorithm for computing gcd of two numbers
def euclid(a,b):
	c=a%b
	if c==0:
		return b
	else:
		return euclid(b,c)
#Main Program
a=int(raw_input())
b=int(raw_input())
print euclid(a,b)