Broken lcm

B

Bret Jolly

Ruby version: ruby 1.9.0 (2004-05-10) [i686-linux]
The lcm method used by mathn (and defined in rational.rb)
is broken.
irb(main):001:0> require 'mathn'
true
irb(main):002:0> 4.lcm(6)
12
irb(main):003:0> 0.lcm(0)
ZeroDivisionError: divided by 0
from /usr/local/lib/ruby/1.9/rational.rb:319:in `div'
from /usr/local/lib/ruby/1.9/rational.rb:319:in `lcm'
from (irb):3
But the lcm of 0 and 0 is well-defined (and equal to 0).

Regards, Bret
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top