Created
June 1, 2016 11:51
-
-
Save EdDeAlmeidaJr/70a70028c4578fbabf52882540b39976 to your computer and use it in GitHub Desktop.
A function to tell if a integer is prime or not.
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
def prime?(n) | |
res = true | |
(2..n-1).each{ |d| res = res && (not ((n%d)==0)) } | |
return res | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment