diff --git a/Algorithms.py b/Algorithms.py index 26fa100..5bff7ef 100644 --- a/Algorithms.py +++ b/Algorithms.py @@ -220,3 +220,12 @@ def getPermutations(master: str, num: int = 0) -> list: perms.sort() #Return the list return perms + +#This function returns the GCD of the two numbers sent to it +def gcd(num1: int, num2: int) -> int: + while((num1 != 0) and (num2 != 0)): + if(num1 > num2): + num1 %= num2 + else: + num2 %= num1 + return num1 | num2