Created
July 5, 2011 11:20
-
-
Save Zolomon/1064668 to your computer and use it in GitHub Desktop.
Least Common Multiple
This file contains hidden or 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
| #!/usr/local/bin/python3.2 | |
| def gcd(a, b): | |
| if a == 0: | |
| return b | |
| while b != 0: | |
| if a > b: | |
| a = a - b | |
| else: | |
| b = b - a | |
| return a | |
| def lcm(a, b): | |
| if a == 0: | |
| return 0 | |
| return a * b / gcd(a, b) | |
| a = float(input("a: ")) | |
| b = float(input("b: ")) | |
| print("LCM({0}, {1}) = {2}".format(a, b, lcm(a,b))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment