svmartin
2/2/2017 - 1:20 AM

sieve_1_prime_7.rb

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

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

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

# "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]"