Skip to content

Instantly share code, notes, and snippets.

@gouf
Created January 10, 2014 21:40
Show Gist options
  • Save gouf/8363223 to your computer and use it in GitHub Desktop.
Save gouf/8363223 to your computer and use it in GitHub Desktop.
require 'pp'
max = 100
first_prime = 2
prime = [2]
list = (2..max).to_a
i = 2
while list.size > 1 do
list = list.select{|x| x % i != 0}
prime << list.first
i = list.first
end
pp prime
=begin
[2,
3,
5,
7,
11,
13,
17,
19,
23,
29,
31,
37,
41,
43,
47,
53,
59,
61,
67,
71,
73,
79,
83,
89,
97]
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment