#B2128. Count Prime Numbers in a Range
Count Prime Numbers in a Range
Count Prime Numbers in a Range
You are given a positive integer n (with n > 2). Your task is to calculate the number of prime numbers in the interval \([2, n]\). A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
Formula:
\( \text{result} = \sum_{i=2}^{n} \mathbb{1}_{\text{i is prime}} \)
where \(\mathbb{1}_{\text{condition}}\) equals 1 if the condition is true, and 0 otherwise.
inputFormat
The input consists of a single line containing a positive integer n (n > 2).
outputFormat
Output a single integer representing the number of prime numbers in the range \([2, n]\).
sample
10
4