Last active
December 10, 2015 19:19
-
-
Save enile8/4480899 to your computer and use it in GitHub Desktop.
Finding the lowest common multiple with python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gcd(arg1, arg2): | |
while arg2 > 0: arg1,arg2 = arg2, arg1 % arg2 | |
return arg1 | |
def contest1(arg1, arg2): | |
result = arg1 * arg2 / gcd(arg1,arg2) | |
return result | |
num1 = int(raw_input('Enter the first number:\n')) | |
num2 = int(raw_input('Enter the second number:\n')) | |
print 'the lcm is %s '% contest1(num1, num2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment