Given an integer D, the task is to find the sum of all the prime numbers whose count of digits is less than or equal to D.
Input: D = 2
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43,
47, 53, 59, 61, 67, 71, 73, 79, 83, 89 and 97 are
the prime numbers having digits less than or equal
to 2 and the sum of these prime numbers is 1060.
Input: D = 3
Approach: Generate all prime numbers using Sieve of Eratosthenes upto maximum D-digit number then find the sum of all the prime numbers in the same range.
Below is the implementation of the above approach:
- Count Numbers in Range with difference between Sum of digits at even and odd positions as Prime
- Print prime numbers with prime sum of digits in an array
- Sum of prime numbers without odd prime digits
- Find all the prime numbers of given number of digits
- Find count of Almost Prime numbers from 1 to N
- Count of numbers below N whose sum of prime divisors is K
- Count all the numbers less than 10^6 whose minimum prime factor is N
- Numbers in range [L, R] such that the count of their divisors is both even and prime
- Sum of numbers in a range [L, R] whose count of divisors is prime
- Count different numbers possible using all the digits their frequency times
- Count numbers formed by given two digit with sum having given digits
- Count the number of digits of palindrome numbers in an array
- Queries for the difference between the count of composite and prime numbers in a given range
- Count of distinct sums that can be obtained by adding prime numbers from given arrays
- Absolute difference between the Product of Non-Prime numbers and Prime numbers of an Array
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.