Skip to content

Instantly share code, notes, and snippets.

@jarsen
Created November 20, 2009 20:06
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 jarsen/239731 to your computer and use it in GitHub Desktop.
Save jarsen/239731 to your computer and use it in GitHub Desktop.
print "x = "
x = gets.chomp.to_i
print "y = "
y = gets.chomp.to_i
# repeat until y = 0
until y == 0
# Assign x <- x mod y
puts "x = #{x} % #{y} = #{x%y} "
x = x % y
# exchange x and y
puts "exchange x (#{x}) and y % (#{y}) "
x,y = y,x
end
# If the result is 1, accept. Otherwise reject.
puts x == 1 ? "Accept!" : "Reject"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment