You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

10 lines
202 B
Ruby

# Computes the greatest common divisor of two nonnegative integers p and q,
# see test/gcd_test.rb
module CommonDivisor
def self.gcd(p, q)
return p if q == 0
r = p % q
gcd(q, r)
end
end