Created
November 12, 2020 11:14
-
-
Save thinkphp/c39947068461b2e33d459eda51962581 to your computer and use it in GitHub Desktop.
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 euclid_it a, b | |
while b != 0 | |
r = a % b | |
a, b = b, r | |
end | |
a | |
end | |
def euclid_rec a, b | |
if b == 0 | |
a | |
else | |
euclid_rec(b, a % b) | |
end | |
end | |
def main | |
#print "a = " | |
#a = gets.to_i | |
#print "b = " | |
#b = gets.to_i | |
#c = euclid_rec(a,b) | |
#print c | |
a = ARGV[0].to_i | |
b = ARGV[1].to_i | |
c = euclid_rec(a,b) | |
p c | |
end | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment