=begin The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below one million. =end upbound = 1000000 nums = [] 2.upto upbound do nums.push true end nums.each_index do |i| if nums[i] == true j = 2*i+2 while j <= (upbound - 2) nums[j] = false j += (i+2) end end end sum = 0 nums.each_index do |i| sum += (i + 2) if nums[i] end print(sum)