mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* array.c (rb_ary_update): pedantic check to detect
rb_ary_to_ary() to modify the receiver. [ruby-dev:24861] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
30b3ce3445
commit
67d54f209d
5 changed files with 30 additions and 16 deletions
|
@ -312,20 +312,22 @@ class Integer
|
|||
return a
|
||||
end
|
||||
|
||||
def lcm(int)
|
||||
a = self.abs
|
||||
b = int.abs
|
||||
gcd = a.gcd(b)
|
||||
(a.div(gcd)) * b
|
||||
def lcm(other)
|
||||
if self.zero? or other.zero?
|
||||
0
|
||||
else
|
||||
(self.div(self.gcd(other)) * other).abs
|
||||
end
|
||||
end
|
||||
|
||||
def gcdlcm(int)
|
||||
a = self.abs
|
||||
b = int.abs
|
||||
gcd = a.gcd(b)
|
||||
return gcd, (a.div(gcd)) * b
|
||||
def gcdlcm(other)
|
||||
gcd = self.gcd(other)
|
||||
if self.zero? or other.zero?
|
||||
[gcd, 0]
|
||||
else
|
||||
[gcd, (self.div(gcd) * other).abs]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Fixnum
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue