Skip to content

Instantly share code, notes, and snippets.

@suryart
Created December 21, 2013 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suryart/8071420 to your computer and use it in GitHub Desktop.
Save suryart/8071420 to your computer and use it in GitHub Desktop.
check prime number
def is_prime?(num)
return false if num <= 1
2.upto(Math.sqrt(num).to_i) do |x|
return false if num%x == 0
end
true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment