Created
December 17, 2013 16:19
-
-
Save st98/8007640 to your computer and use it in GitHub Desktop.
Rubyの練習。2つの整数の最小公倍数を求めます。
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(a, b) | |
if b == 0 then | |
a | |
else | |
gcd(b, a % b) | |
end | |
end | |
def lcm(a, b) | |
a * b / gcd(a, b) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment