Skip to content

Instantly share code, notes, and snippets.

@RickArora
Created November 23, 2018 01:35
Show Gist options
  • Save RickArora/ec4fad3599f7252554bd47f412d00a62 to your computer and use it in GitHub Desktop.
Save RickArora/ec4fad3599f7252554bd47f412d00a62 to your computer and use it in GitHub Desktop.
# Write a method that returns a boolean indicating whether the argument is
# prime.
def prime?(num)
(1..num).each do |i|
if (num % i == 0 && i != 1 && i != num) || (num == 1)
return false
end
end
return true;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment