# Write a python function to calculate the greatest common divisor (GCD) of two user provided positive integers.

## Topic: Write a python function to calculate the greatest common divisor (GCD) of two user provided positive integers.

Solution

def gcd(num1, num2): gcd = 1 if num1 % num2 == 0: return num2 for k in range(int(num2 / 2), 0, -1): if num1 % k == 0 and num2 % k == 0: gcd = k break return gcd

List all Python Programs