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
- Check if a number is Prime, Semi-Prime or Composite for very large numbers
- 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
- Recursive sum of digits of a number is prime or not
- Largest number with prime digits
- Finding n-th number made of prime digits (2, 3, 5 and 7) only
- Find smallest number with given number of digits and sum of digits under given constraints
- Largest number not greater than N which can become prime after rearranging its digits
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.