Given an integer D, the task is to find all the prime numbers having D digits.
Input: D = 1
Output: 2 3 5 7
Input: D = 2
Output: 11 13 17 19 23 29 31 37 41 43 47 53 61 67 71 73 79 83 89 97
Approach: Numbers with D digits lie in the range [10(D – 1), 10D – 1]. So, check all the numbers in this interval and to check the number is prime or not, use Sieve of Eratosthenes to generate all the primes.
Below is the implementation of the above approach:
2 3 5 7
- Print prime numbers with prime sum of digits in an array
- Numbers with sum of digits equal to the sum of digits of its all prime factor
- Find a sequence of N prime numbers whose sum is a composite number
- Sum of prime numbers without odd prime digits
- Sum of all the prime numbers with the count of digits ≤ D
- Count Numbers in Range with difference between Sum of digits at even and odd positions as Prime
- Print the nearest prime number formed by adding prime numbers to N
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Check if a prime number can be expressed as sum of two Prime Numbers
- Largest number with prime digits
- Recursive sum of digits of a number is prime or not
- Finding n-th number made of prime digits (2, 3, 5 and 7) only
- Largest number not greater than N which can become prime after rearranging its digits
- Find coordinates of a prime number in a Prime Spiral
- Number of Co-prime pairs obtained from the sum of digits of elements in the given range
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.