#K51012. Count Primes in Range
Count Primes in Range
Count Primes in Range
Given two integers L and R, your task is to count the number of prime numbers in the inclusive range [L, R]. A prime number is defined as a natural number greater than 1 that has no positive divisors other than 1 and itself. In other words, a number \( n \) is prime if and only if for every integer \( p \) with \(2 \le p \le \sqrt{n}\), we have \(n \mod p \neq 0\).
Your solution should read the input from standard input (stdin) and output the result to standard output (stdout).
inputFormat
The input consists of a single line containing two space-separated integers L and R where L
and R
satisfy \(1 \leq L \leq R \leq 10^6\).
outputFormat
Output a single integer representing the number of prime numbers in the range [L, R].
## sample10 20
4