How to Calculate the GCD (Greatest Common Divisor) of Two Numbers in Python

import math

num1, num2 = 24, 36
gcd = math.gcd(num1, num2)
print(f"GCD of {num1} and {num2}: {gcd}")

Output:

GCD of 24 and 36: 12

Leave a Comment

Your email address will not be published.