Prime sum
Practice
3 (4 votes)
Special numbers
Counting
Implementation
Math basic
Basic programming
Basic math
Basics of implementation
Sieve
Math
Problem
94% Success 1604 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given a number \(N\). Find all pairs of prime numbers \((L,R)\) such that \(L ≤ R\) 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
\(1 ≤ N ≤ 10^7\)
Explanation
If first case is one pair (\(L,R\)) which suits us - \((2,3)\), because \(2 + 3 = 5\) , \(5 \) - prime number.
Code Editor
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
7 votes
Tags:
Dynamic ProgrammingRecursionAlgorithmsEasyMathematicsOpenApproved
Points:20
155 votes
Tags:
MathematicsLucky-DigitEasySimple-math
Points:20
21 votes
Tags:
Bit manipulationBasic ProgrammingApprovedEasyBit manipulation
Editorial
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output