Created
June 14, 2013 20:24
-
-
Save joegiralt/5784986 to your computer and use it in GitHub Desktop.
prime.rb
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 sqrt(y) | |
y = y ** 0.5 | |
return y | |
end | |
def is_prime(x) | |
return false if x <= 1 | |
2.upto(sqrt(x).to_i).any do |x| | |
return false if x %x == 0 | |
end | |
true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment