Skip to content

Commit 9f8953d

Browse files
thiru15cclauss
authored andcommitted
Update find_lcm.py (#1019)
* Update find_lcm.py Improved code quality and added comments. * Make the doctests work
1 parent f438440 commit 9f8953d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Diff for: maths/find_lcm.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@
44

55

66
def find_lcm(num_1, num_2):
7-
"""Find the LCM of two numbers."""
8-
max_num = num_1 if num_1 > num_2 else num_2
7+
"""Find the least common multiple of two numbers.
8+
>>> find_lcm(5,2)
9+
10
10+
>>> find_lcm(12,76)
11+
228
12+
"""
13+
if num_1>=num_2:
14+
max_num=num_1
15+
else:
16+
max_num=num_2
17+
918
lcm = max_num
1019
while True:
1120
if ((lcm % num_1 == 0) and (lcm % num_2 == 0)):
@@ -16,8 +25,8 @@ def find_lcm(num_1, num_2):
1625

1726
def main():
1827
"""Use test numbers to run the find_lcm algorithm."""
19-
num_1 = 12
20-
num_2 = 76
28+
num_1 = int(input().strip())
29+
num_2 = int(input().strip())
2130
print(find_lcm(num_1, num_2))
2231

2332

0 commit comments

Comments
 (0)