Given an integer N, the task is to find the count of all the primes below N which can be expressed as the sum of two primes.
Input: N = 6
5 is the only such prime below 6.
2 + 3 = 5.
Input: N = 11
Approach: Create an array prime where prime[i] will store whether i is prime or not using Sieve of Eratosthenes. Now for every prime from the range [1, N – 1], check whether it can be expressed as the sum of two primes using the approach discussed here.
Below is the implementation of the above approach:
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Count primes that can be expressed as sum of two consecutive primes and 1
- Check if an integer can be expressed as a sum of two semi-primes
- Length of largest sub-array having primes strictly greater than non-primes
- Count Primes in Ranges
- Count number of primes in an array
- Count of interesting primes upto N
- Count numbers < = N whose difference with the count of primes upto them is > = K
- Count numbers which can be represented as sum of same parity primes
- Maximum count of common divisors of A and B such that all are co-primes to one another
- Count of primes after converting given binary number in base between L to R
- Count the number of primes in the prefix sum array of the given array
- Circular primes less than n
- Palindromic Primes
- Product of all primes in the range from L to R
- Maximum Primes whose sum is equal to given N
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.