Last active
September 11, 2015 21:29
-
-
Save rvalenciano/9013b82e1691df83e732 to your computer and use it in GitHub Desktop.
Is a number prime?
This file contains 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
# Test if number is prime | |
def isPrime(num) | |
for d in 2..(num - 1) | |
if (num % d) == 0 | |
return false | |
end | |
end | |
true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Given a number, define if it's a prime number or no