Skip to content

Instantly share code, notes, and snippets.

@elsapet
Last active August 29, 2015 14:27
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 elsapet/a3f9685cae5bc9e64fb3 to your computer and use it in GitHub Desktop.
Save elsapet/a3f9685cae5bc9e64fb3 to your computer and use it in GitHub Desktop.
n = 100000
primes = (0..n).select{ |i| i if (2..i-1).select{ |j| j if i%j == 0}.count == 0}
puts primes.inspect # => [1, 2, 3, 5, 7, ..., 9973]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment