Skip to content

Instantly share code, notes, and snippets.

@itzsaga
Created March 8, 2017 04:37
Show Gist options
  • Save itzsaga/4e1efbe7d7bd36ebdedd716edf12d56c to your computer and use it in GitHub Desktop.
Save itzsaga/4e1efbe7d7bd36ebdedd716edf12d56c to your computer and use it in GitHub Desktop.
def prime?(n)
if n <= 1
return false
elsif n <= 3
return true
else (2..n/2).none? do |x|
n % x == 0
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment