Skip to content

Instantly share code, notes, and snippets.

@josephsiefers
Last active September 24, 2015 01:21
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 josephsiefers/f2abc3c9201e44c3f47d to your computer and use it in GitHub Desktop.
Save josephsiefers/f2abc3c9201e44c3f47d to your computer and use it in GitHub Desktop.
Simple Prime
def prime? n
for d in 2..(n - 1)
if (n % d) == 0
return false
end
end
#implicit return of the range from the for loop unless you return a value yourself, as seen below:
return true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment