Problems > Twin Prime Pairs

Twin Prime Pairs

Difficulty: 1400 3000 ms 128 MB

math number-theory

Count the twin prime pairs (p, p+2) with both members ≤ N.

Input: one integer N.

Output: the number of twin prime pairs with p+2 ≤ N.

Constraints:

  • 1 ≤ N ≤ 106

Sample Tests

Input 1
13
Output 1
3
Input 2
4
Output 2
0

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.