Woodall Primes are prime numbers that are also Woodall number.
Find the Woodall prime numbers less than N
Given a number N, print all Woodall primes smaller than or equal to N.
Input: N = 10
Input: N = 500
Output: 7, 23, 383
Approach: The idea is to use Sieve of Eratosthenes to check that a number is prime or not efficiently. Then, Iterate over integers from 1 to N, and for every number check that if it is prime or not and it is Woodall number or not. If a number is prime also a Woodall number, Then it a Woodall prime.
Below is the implementation of above algorithm:
7 23 383
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. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.