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/e5d7aafae6534ec9bc38 to your computer and use it in GitHub Desktop.
Save elsapet/e5d7aafae6534ec9bc38 to your computer and use it in GitHub Desktop.
n = 100
primes = (1..n).map{ |i| i if (2..i-1).map{ |j| j if i%j == 0}.compact.count == 0}.compact
puts primes.inspect # => [1, 2, 3, 5, 7, ..., 97]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment