Last active
November 7, 2018 07:03
-
-
Save krvajal/b5ce2ade8556fdb296989b8ffe7e0ae0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prime?(number, primes) | |
true unless !primes.empty? | |
to_check = primes.select do |x| | |
x*x < number | |
end | |
to_check.any? do |divisor| | |
# puts "#{number}, #{divisor}" | |
(number % divisor).zero? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment