using System; using System.Text; using System.Linq; using System.Collections; using System.Collections.Generic; using System.Runtime.Serialization.Formatters; using static System.Console; using static System.Math; namespace YukiCoder { public class Program { public static void Main(string[] args) { new Program().Solve(); } public void Solve() { int N = int.Parse(Console.ReadLine()); int n = 1000; bool[] primes = SieveOfEratosthenes(n); int sum = 0; for (int i = 0; i <= N; i++) { if (primes[i]) { sum += i; } } WriteLine(sum); } public static bool[] SieveOfEratosthenes(int n) { bool[] isPrime = new bool[n+1]; for (int i = 0; i < n; i++) { isPrime[i] = true; } isPrime[0] = false; isPrime[1] = false; for (int i = 2; i < Math.Sqrt(n); i++) { int j; if (isPrime[i]) { j = i + i; while (j <= n) { isPrime[j] = false; j = j + i; } } } return isPrime; } } }