def prime?(n) return false if n == 0 or n == 1 res = true n.times do |i| next if i == 0 or i == 1 if n % i == 0 res = false break end end res end max = gets.chomp.to_i res = [] (0..max).each do |i| res << i if prime?(i) end puts res.inject { |sum, k| sum + k}