Implement greater common divisor algorithm

relate to forga/process/fr/embarquement#6
This commit is contained in:
freezed 2021-04-13 23:51:07 +02:00
parent 165d391a4a
commit 4058a733a9
1 changed files with 14 additions and 1 deletions

View File

@ -18,4 +18,17 @@ def pgcd(a,b):
This function find the Greatest Common Divisor (PGCD in French)
between a & b
"""
pass
rest = a - b
check = b - rest
while check != 0:
a = max(b, rest)
b = min(b, rest)
rest = a - b
check = max(b, rest) - min(b, rest)
print(rest)
if __name__ == '__main__':
pgcd(561, 357)