Greatest common divisor in Python

Download source

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#!/usr/bin/python

def gcd(a,b):
	if b==0:
		return a
	return gcd(b,a%b)


print gcd(110,10)
print gcd(1407,3441)
print gcd(12,42)
print gcd(3121,73165603)
print gcd(3072,8388608)