svmartin
2/2/2017 - 1:17 AM

sieve_1_prime_3.rb

range = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39,
        41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75,
        77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]
primes = [2]
prime = range.delete_at(0)
primes << prime
range.delete_if { |number| number % prime == 0 }

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

# "range: [5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, 37, 41, 43, 47, 49, 53, 55, 59, 
# 61, 65, 67, 71, 73, 77, 79, 83, 85, 89, 91, 95, 97]"
# ===========
# "primes: [2, 3]"