Skip to content

Instantly share code, notes, and snippets.

@andruby
Created May 26, 2011 08:28
Show Gist options
  • Save andruby/992773 to your computer and use it in GitHub Desktop.
Save andruby/992773 to your computer and use it in GitHub Desktop.
Find the first 1000 primes quickly in Ruby
getal = 2
primes = [2]
begin
getal += 1
primes << getal unless primes.any? { |deler| getal % deler == 0 }
end until primes.size >= 1000
p primes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment