Method: Integer#gcd
- Defined in:
- rational.c
#gcd(other_int) ⇒ Integer
Returns the greatest common divisor of the two integers. The result is always positive. 0.gcd(x) and x.gcd(0) return x.abs.
36.gcd(60) #=> 12
2.gcd(2) #=> 2
3.gcd(-7) #=> 1
((1<<31)-1).gcd((1<<61)-1) #=> 1
1914 1915 1916 1917 1918 1919 |
# File 'rational.c', line 1914 VALUE rb_gcd(VALUE self, VALUE other) { other = nurat_int_value(other); return f_gcd(self, other); } |