mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-01-19 00:37:02 +00:00
Rename GCD File (#1354)
This commit is contained in:
parent
67291a5bce
commit
b190c8f629
|
@ -1,12 +1,12 @@
|
||||||
"""
|
"""
|
||||||
Greater Common Divisor.
|
Greatest Common Divisor.
|
||||||
|
|
||||||
Wikipedia reference: https://en.wikipedia.org/wiki/Greatest_common_divisor
|
Wikipedia reference: https://en.wikipedia.org/wiki/Greatest_common_divisor
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def gcd(a, b):
|
def gcd(a, b):
|
||||||
"""Calculate Greater Common Divisor (GCD)."""
|
"""Calculate Greatest Common Divisor (GCD)."""
|
||||||
return b if a == 0 else gcd(b % a, a)
|
return b if a == 0 else gcd(b % a, a)
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@ def main():
|
||||||
nums = input("Enter two Integers separated by comma (,): ").split(",")
|
nums = input("Enter two Integers separated by comma (,): ").split(",")
|
||||||
num_1 = int(nums[0])
|
num_1 = int(nums[0])
|
||||||
num_2 = int(nums[1])
|
num_2 = int(nums[1])
|
||||||
|
print(f"gcd({num_1}, {num_2}) = {gcd(num_1, num_2)}")
|
||||||
except (IndexError, UnboundLocalError, ValueError):
|
except (IndexError, UnboundLocalError, ValueError):
|
||||||
print("Wrong Input")
|
print("Wrong Input")
|
||||||
print(f"gcd({num_1}, {num_2}) = {gcd(num_1, num_2)}")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
Loading…
Reference in New Issue
Block a user