Bertrand's Postulate

Time limit1sMemory limit256 MB

Summary
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 nn, there exists at least one prime pp with n<p≤2nn < p \le 2n.

The statement was conjectured in 1845 and proved in 1850.

For example, there are 4 primes greater than 1010 and at most 2020: 11,13,17,1911, 13, 17, 19. Likewise, there are 3 primes greater than 1414 and at most 2828: 17,19,2317, 19, 23.

Given a natural number nn, write a program that counts the primes pp satisfying n<p≤2nn < p \le 2n.

Input

The input consists of several test cases. Each case is a single line containing a natural number nn.

The last line of the input contains 00; this line is not processed.

Output

For each test case, print on its own line the number of primes pp with n<p≤2nn < p \le 2n.

Constraints

  • 1≤n≤1234561 \le n \le 123456

Examples1

  1. Example 1

    Input
    1
    10
    13
    100
    1000
    10000
    100000
    0
    
    Expected output
    1
    4
    3
    21
    135
    1033
    8392