Find all circular primes less than given number n. A prime number is a Circular Prime Number if all of its possible rotations are itself prime numbers.
79 is a circular prime. as 79 and 97 are prime numbers. But 23 is not a circular prime. as 23 is prime but 32 is not a prime number.
-> Find prime numbers up to n using Sieve of Sundaram algorithm. -> Now for every prime number from sieve method, one after another, we should check whether its all rotations are prime or not: -> If yes then print that prime number. -> If no then skip that prime number.
Below is the implementation of the above algorithm :
2 3 5 7 11 13 17 31 37 71 73 79 97
This article is contributed by Shivam Pradhan (anuj_charm). 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
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.
- Length of largest sub-array having primes strictly greater than non-primes
- Count primes that can be expressed as sum of two consecutive primes and 1
- Count of primes below N which can be expressed as the sum of two primes
- Nth Term of a Fibonacci Series of Primes formed by concatenating pairs of Primes in a given range
- Largest number with maximum trailing nines which is less than N and greater than N-D
- Largest number less than N with digit sum greater than the digit sum of N
- Highest and Smallest power of K less than and greater than equal to N respectively
- Sieve of Sundaram to print all primes smaller than n
- Nearest prime less than given number n
- C++ program to find all numbers less than n, which are palindromic in base 10 and base 2.
- Generate all palindromic numbers less than n
- Highest power of 2 less than or equal to given number
- Check if frequency of each digit is less than the digit
- Count pairs with sum as a prime number and less than n
- Count of integers of length N and value less than K such that they contain digits only from the given set
- Number of subarrays having product less than K
- Find all factorial numbers less than or equal to n
- Largest number less than N whose each digit is prime number
- Sum of largest prime factor of each number less than equal to n
- Smallest even digits number not less than N