Given an integer N. The task is to find the sum of the first N prime numbers which don’t contain any odd primes as their digit.
Some of such prime numbers are 2, 11, 19, 29, 41 ……
Input : N = 2
Output : 13
2 + 11 = 13
Input : N = 7
Output : 252
- We first use a Sieve of Eratosthenes to store all prime numbers.
- Next check for each prime number if any odd prime digit is present or not.
- If no such digit is present then we will include this prime to our required answer
- Continue above step until we get N such prime numbers
Below is the implementation of the above approach :
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Count numbers from given range having odd digits at odd places and even digits at even places
- Count numbers in given range such that sum of even digits is greater than sum of odd digits
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Numbers with sum of digits equal to the sum of digits of its all prime factor
- Numbers of Length N having digits A and B and whose sum of digits contain only digits A and B
- Count of numbers upto N digits formed using digits 0 to K-1 without any adjacent 0s
- Count Numbers in Range with difference between Sum of digits at even and odd positions as Prime
- Count of N-digit Numbers having Sum of even and odd positioned digits divisible by given numbers
- Check whether product of digits at even places is divisible by sum of digits at odd place of a number
- Number formed by deleting digits such that sum of the digits becomes even and the number odd
- Print prime numbers with prime sum of digits in an array
- Count all prime numbers in a given range whose sum of digits is also prime
- Minimum digits to be removed to make either all digits or alternating digits same
- Count total number of N digit numbers such that the difference between sum of even and odd digits is 1
- Print all n-digit numbers with absolute difference between sum of even and odd digits is 1
- Count numbers with exactly K non-zero digits and distinct odd digit sum
- Print numbers such that no two consecutive numbers are co-prime and every three consecutive numbers are co-prime
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Absolute Difference between the Sum of Non-Prime numbers and Prime numbers of an Array
- Count prime numbers that can be expressed as sum of consecutive prime numbers
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.