On Tue, Dec 06, 2016, Micky Scandal wrote:
> so I was just working on an exorcize using the Prime module and on one test
> out of like 50 I was getting an error, so after some digging around I found
> this:
> 
> irb(main):001:0> require 'prime'
> => true
> irb(main):002:0> 8.prime_division
> => [[2, 3]]
> 
> 
> that should be the factors of 8, but unless I'm totally out of my mind and
> my math is WAY worse than I thought, I don't think 3 is a factor of 5.
> pretty sure that should be 4.

Go back and read the documentation carefully:
https://ruby-doc.org/stdlib-2.3.0/libdoc/prime/rdoc/Prime.html#method-i-prime_division

> every other number I tried ranging from single digit numbers to numbers up
> to the millions worked just fine, it was just that 8 being all wonky.

What do you mean by "worked just fine"? For instance, is the result [[2,
2]] correct for 4.prime_division? How about 2.prime_division being [[2,
1]]? If you accept those as working, you should be able to see how the
result you got fits into the big picture. Once you've developed a
hypothesis for these numbers, try doing #prime_division on numbers that
have factors other than 2.

> anyone run across this before? is there some logical explanation as to why
> I would get a 3 there? or is this just a bug I should go report to....
> wherever you report ruby bugs to?

-- 
        Eric Christopherson

Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>