Skip to content

Instantly share code, notes, and snippets.

@atton
Created May 2, 2012 14:27
Show Gist options
  • Save atton/2576895 to your computer and use it in GitHub Desktop.
Save atton/2576895 to your computer and use it in GitHub Desktop.
prime check
def prime? num
return 0 if num == 1
(num-1).downto(2) do |n|
return 0 if num.modulo(n) == 0
end
return 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment