#C4693. Count Primes

    ID: 48259 Type: Default 1000ms 256MiB

Count Primes

Count Primes

Given an integer (N), count the number of prime numbers less than or equal to (N). A prime number is defined as a natural number greater than 1 that has no divisors other than 1 and itself. In other words, if (\pi(N)) represents the number of primes less than or equal to (N), your task is to compute (\pi(N)). For example, if (N = 10), the primes are 2, 3, 5, and 7, so (\pi(10) = 4). Use an efficient algorithm such as the Sieve of Eratosthenes to handle larger inputs.

inputFormat

Standard input consists of a single integer (N). Note that (N) may be negative or zero; in these cases, there are no primes and the answer is 0.

outputFormat

Output a single integer representing the count of prime numbers less than or equal to (N) to standard output.## sample

10
4

</p>