Last active
September 5, 2015 03:39
-
-
Save paralleltree/133ddfb3175045c4b664 to your computer and use it in GitHub Desktop.
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/bin/env ruby | |
if (ARGV.count != 2) | |
puts 'Invalid number of arguments.' | |
exit | |
end | |
a, b = ARGV.map { |s| s.to_i } | |
get_gcd = -> (m, n) do | |
m, n = n, m if m < n | |
return m if n == 0 | |
get_gcd[n, m % n] | |
end | |
gcd = get_gcd[a, b] | |
puts "#{a} : #{b} = #{a / gcd} : #{b / gcd}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment