From 03abc2a5eb3131d2207724bf665b3d2155a284e9 Mon Sep 17 00:00:00 2001 From: thiru15 <33665749+thiru15@users.noreply.github.com> Date: Sun, 14 Jul 2019 14:24:28 +0530 Subject: [PATCH 1/2] Update find_lcm.py Improved code quality and added comments. --- maths/find_lcm.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/maths/find_lcm.py b/maths/find_lcm.py index 9062d462b8b3..d8bb0d1cf3d0 100644 --- a/maths/find_lcm.py +++ b/maths/find_lcm.py @@ -4,8 +4,17 @@ def find_lcm(num_1, num_2): - """Find the LCM of two numbers.""" - max_num = num_1 if num_1 > num_2 else num_2 + """Find the Least common multiple of two numbers. + >>find_lcm(5,2) + 10 + >>find_lcm(12,76) + 228 + """ + if num_1>=num_2: + max_num=num_1 + else: + max_num=num_2 + lcm = max_num while True: if ((lcm % num_1 == 0) and (lcm % num_2 == 0)): @@ -16,8 +25,8 @@ def find_lcm(num_1, num_2): def main(): """Use test numbers to run the find_lcm algorithm.""" - num_1 = 12 - num_2 = 76 + num_1 = int(input().strip()) + num_2 = int(input().strip()) print(find_lcm(num_1, num_2)) From c00550629d1260dc3a9193fdf5110ee2ed4479f1 Mon Sep 17 00:00:00 2001 From: cclauss Date: Thu, 18 Jul 2019 23:26:03 +0200 Subject: [PATCH 2/2] Make the doctests work --- maths/find_lcm.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/maths/find_lcm.py b/maths/find_lcm.py index d8bb0d1cf3d0..f7ac958070b5 100644 --- a/maths/find_lcm.py +++ b/maths/find_lcm.py @@ -4,11 +4,11 @@ def find_lcm(num_1, num_2): - """Find the Least common multiple of two numbers. - >>find_lcm(5,2) - 10 - >>find_lcm(12,76) - 228 + """Find the least common multiple of two numbers. + >>> find_lcm(5,2) + 10 + >>> find_lcm(12,76) + 228 """ if num_1>=num_2: max_num=num_1