Skip to content

Commit b56fd88

Browse files
Merge pull request #136 from eliaszak/eliaszak-gcd-feature
Implemented GCD function
2 parents be1247e + 3ef079a commit b56fd88

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def gcd(a: int, b: int) -> int:
2+
if not isinstance(a, int) or not isinstance(b, int):
3+
print("Error: Both inputs must be integers.")
4+
return None
5+
if a == 0 and b == 0:
6+
print("Error: GCD is undefined for both inputs zero.")
7+
return None
8+
if b == 0:
9+
return abs(a)
10+
return gcd(b, a % b)
11+
12+
print(gcd(54, 24))
13+
print(gcd(48, 18))
14+
print(gcd(101, 10))

0 commit comments

Comments
 (0)