Skip to content

Instantly share code, notes, and snippets.

@EdDeAlmeidaJr
Created June 1, 2016 11:51
Show Gist options
  • Save EdDeAlmeidaJr/70a70028c4578fbabf52882540b39976 to your computer and use it in GitHub Desktop.
Save EdDeAlmeidaJr/70a70028c4578fbabf52882540b39976 to your computer and use it in GitHub Desktop.
A function to tell if a integer is prime or not.
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