summaryrefslogtreecommitdiff
path: root/day1/exercise/gcd_another.py
diff options
context:
space:
mode:
Diffstat (limited to 'day1/exercise/gcd_another.py')
-rw-r--r--day1/exercise/gcd_another.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/day1/exercise/gcd_another.py b/day1/exercise/gcd_another.py
new file mode 100644
index 0000000..fe9e6a6
--- /dev/null
+++ b/day1/exercise/gcd_another.py
@@ -0,0 +1,13 @@
+def gcd(a, b):
+ if a - b == 0:
+ return b
+ if a > b:
+ return gcd(b, a-b)
+ else:
+ return gcd(b, b-a)
+
+def lcm(a, b):
+ return (a * b) / gcd(a, b)
+
+print lcm(21, 14)
+