Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.20 KB | None | 0 0
  1. def divisors(n)
  2.   divisors = Array.new
  3.  
  4.   for i in 2..n-1
  5.     if (n % i == 0)
  6.       divisors << i
  7.     end
  8.   end
  9.  
  10.   if divisors.empty?
  11.     "#{n} is prime"
  12.   else
  13.     divisors
  14.   end
  15. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement