Tuesday, 20 August 2013

What is the explanation for rubeque prime factors?

What is the explanation for rubeque prime factors?

So this is my code, the thing that is bugging me is this line " { |i| (num
% i) == 0}.length == 0? "can someone eloborate calling .length on a block?
I am trying to answer a rubeque problem prime factors
divisors = Array.new
for d in 2..(num)
divisors << d if (num % d) == 0
end
primes = divisors.select do |num|
(2..(num-1)).select { |i| (num % i) == 0}.length == 0
end

No comments:

Post a Comment