From e39a22e298c93998164b6234daf7b288509271c3 Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Sun, 7 Feb 2021 12:42:35 -0500 Subject: [PATCH] Added functions to determine the gcd of 2 nums --- Algorithms.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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