We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 54eb79f + 2480eac commit 6882321Copy full SHA for 6882321
other/euclidean_gcd.py
@@ -0,0 +1,18 @@
1
+# https://en.wikipedia.org/wiki/Euclidean_algorithm
2
+
3
+def euclidean_gcd(a, b):
4
+ while b:
5
+ t = b
6
+ b = a % b
7
+ a = t
8
+ return a
9
10
+def main():
11
+ print("GCD(3, 5) = " + str(euclidean_gcd(3, 5)))
12
+ print("GCD(5, 3) = " + str(euclidean_gcd(5, 3)))
13
+ print("GCD(1, 3) = " + str(euclidean_gcd(1, 3)))
14
+ print("GCD(3, 6) = " + str(euclidean_gcd(3, 6)))
15
+ print("GCD(6, 3) = " + str(euclidean_gcd(6, 3)))
16
17
+if __name__ == '__main__':
18
+ main()
0 commit comments