Forked from IvanTorresEdge/prime_numbers_sieve_eratosthenes.rb
Created
August 14, 2013 11:16
-
-
Save alvinkatojr/6230135 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| n = 2..1000 | |
| o = [] | |
| p = [] | |
| for i in n | |
| next if o.include? i | |
| ii = i * 2 | |
| while ii <= n.last do | |
| o << ii | |
| ii = ii + i | |
| end | |
| p << i unless o.include?(i) | |
| end | |
| puts p.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment