On 2016-12-06 20:37, 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]]

Rule of thumb: when you think you've found a bug in a language, try to 
dig deeper and see what the deal is, because, most likely, it ain't a 
bug.  In this case, you're mis-interpreting the output.  What it's 
telling you is that 8 = 2 ^ 3.  As a different example, let's look at 
10:
irb(main):002:0> 10.prime_division
=> [[2, 1], [5, 1]]

This would be expressed as:
10 = 2^1 * 5^1

So, let's look at 50, which should give us another power:
irb(main):005:0> 50.prime_division
=> [[2, 1], [5, 2]]

Also known as:
50 = 2^1 * 5^2

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

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