diff --git a/prime_factors.rb b/prime_factors.rb new file mode 100644 index 0000000..feb16a8 --- /dev/null +++ b/prime_factors.rb @@ -0,0 +1,10 @@ +require 'prime' +class PrimeFactors + def self.for(num) + return [] if num == 1 + result = [] + num = num.prime_division + num.each { |i| i[1].times { result << i[0] } } + result + end +end