2019-07-01 08:10:18 +00:00
|
|
|
"""Find Least Common Multiple."""
|
|
|
|
|
|
|
|
# https://en.wikipedia.org/wiki/Least_common_multiple
|
|
|
|
|
|
|
|
|
2018-11-23 16:51:07 +00:00
|
|
|
def find_lcm(num_1, num_2):
|
2019-07-18 21:40:51 +00:00
|
|
|
"""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
|
|
|
|
|
2019-07-02 04:05:43 +00:00
|
|
|
lcm = max_num
|
|
|
|
while True:
|
2019-01-19 20:49:06 +00:00
|
|
|
if ((lcm % num_1 == 0) and (lcm % num_2 == 0)):
|
2018-11-23 16:51:07 +00:00
|
|
|
break
|
2019-07-02 04:05:43 +00:00
|
|
|
lcm += max_num
|
2019-01-19 20:49:06 +00:00
|
|
|
return lcm
|
2018-11-23 16:51:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2019-07-01 08:10:18 +00:00
|
|
|
"""Use test numbers to run the find_lcm algorithm."""
|
2019-07-18 21:40:51 +00:00
|
|
|
num_1 = int(input().strip())
|
|
|
|
num_2 = int(input().strip())
|
2018-11-23 16:51:07 +00:00
|
|
|
print(find_lcm(num_1, num_2))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|