Counting Primes in a Range
InterviewTime limit1sMemory limit256 MB
Count the primes between m and n inclusive for each blank-line separated test case.
- Level
Easy3 of 10
- Topics
- Number theory, Prefix sum
- Solved
- No attempts yet
Problem
You are given two integers and with .
Consider the following set.
Here is the set of all primes, so collects every prime that is at least and at most .
Compute the number of elements of .
Input
The input consists of several tests. Each test occupies one line and holds and separated by exactly one space. An empty line separates any two consecutive tests.
Output
For each test, print the number of elements of on its own line, in the same order as the input. Print an empty line between any two consecutive results.