mirror of
https://bitbucket.org/Mattrixwv/pyclasses.git
synced 2025-12-06 18:33:58 -05:00
Added functions to determine the gcd of 2 nums
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user