svmartin
2/2/2017 - 1:21 AM

sieve_1_prime_11.rb

range = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73,
        79, 83, 89, 97]

primes = [2, 3, 5, 7]
prime = range.delete_at(0)
primes << prime
range.delete_if { |number| number % prime == 0 }

p "range: #{range}"
puts "==========="
p "primes: #{primes}"

# "range: [13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]"
# ===========
# "primes: [2, 3, 5, 7, 11]"