Skip to content

Update find_lcm.py #1019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 18, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions maths/find_lcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
    """

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)):
Expand All @@ -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))


Expand Down