Bertrand's Postulate
Time limit1sMemory limit256 MB
For each n until a terminating 0, count how many primes lie strictly above n and at most 2n.
- Level
Medium4 of 10
- Topics
- Number theory, Math, Implementation
- Solved
- No attempts yet
Problem
Bertrand's postulate states that for every natural number , there exists at least one prime with .
The statement was conjectured in 1845 and proved in 1850.
For example, there are 4 primes greater than and at most : . Likewise, there are 3 primes greater than and at most : .
Given a natural number , write a program that counts the primes satisfying .
Input
The input consists of several test cases. Each case is a single line containing a natural number .
The last line of the input contains ; this line is not processed.
Output
For each test case, print on its own line the number of primes with .