Skip to content

Instantly share code, notes, and snippets.

@thinkphp
Created November 12, 2020 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinkphp/c39947068461b2e33d459eda51962581 to your computer and use it in GitHub Desktop.
Save thinkphp/c39947068461b2e33d459eda51962581 to your computer and use it in GitHub Desktop.
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