method
gcd2
v1_8_7_72 -
Show latest stable
-
0 notes -
Class: Integer
- 1_8_6_287 (0)
- 1_8_7_72 (0)
- 1_8_7_330 (0)
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125
- 1_9_3_392
- 2_1_10
- 2_2_9
- 2_4_6
- 2_5_5
- 2_6_3
- What's this?
gcd2(int)
public
Hide source
# File lib/mathn.rb, line 19 def gcd2(int) a = self.abs b = int.abs a, b = b, a if a < b pd_a = a.prime_division pd_b = b.prime_division gcd = 1 for pair in pd_a as = pd_b.assoc(pair[0]) if as gcd *= as[0] ** [as[1], pair[1]].min end end return gcd end