Prime sum

3

4 votes
Special Numbers, Counting, Implementation, Math Basic, Basic Programming, Basic Math, Basics of Implementation, Sieve, Math
Problem

You are given a number N. Find all pairs of prime numbers (L,R) such that LR and their sum is also a prime number and no more N.

Input format

The first line contains a single integer N.

Output format

The single integer is the number of pairs that satisfy the condition.

Constraints

1N107

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

If first case is one pair (L,R) which suits us - (2,3), because 2+3=5 , 5 - prime number.

Editor Image

?