fn get_primes(max: usize) -> Vec { let mut is_prime = vec![true; max + 1]; is_prime[0] = false; is_prime[1] = false; for n in 2.. { if !is_prime[n] { continue; } if n * n > max { break; } for i in ((n * n)..=max).step_by(n) { is_prime[i] = false; } } (0..=max).filter(|&n| is_prime[n]).collect() } fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); println!("{}", get_primes(n).into_iter().sum::()); }