brewersfan1976

prime_factors2.rb

Mar 6th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.27 KB | None | 0 0
  1. def primeFactors2(n)
  2.     require 'prime'
  3.    
  4.     array = Array.new
  5.     x = 2
  6.    
  7.     while (x <= n)
  8.           if n % x == 0 and Prime.prime?(x) then
  9.              array.push(x)
  10.           end
  11.              
  12.           x = x + 1
  13.     end
  14.        
  15.     return array
  16. end
Advertisement
Add Comment
Please, Sign In to add comment