Given a number N, the task is to check whether the given number is Proth Prime or not.
A Proth prime is a Proth Number which is prime.
The first few Proth primes are –
3, 5, 13, 17, 41, 97, 113, 193, 241, 257, 353, 449, 577, 641, 673, 769, 929, 1153, 1217, …..
Input: 41 Output: 41 is Proth Prime Input: 19 Output: 19 is not a Proth Prime
The idea is to find primes upto N using Sieve of Eratosthenes. Then check whether the given number is Proth Number or not. If number is a Proth Number and is also a prime number, then given number is Proth Prime.
Below is the implementation of the above algorithm:
3 5 13 17 41
Time Complexity: O(n*log(log(n)))
- Print all safe primes below N
- Sieve of Sundaram to print all primes smaller than n
- Length of largest sub-array having primes strictly greater than non-primes
- Circular primes less than n
- Palindromic Primes
- Product of all primes in the range from L to R
- Alternate Primes till N
- Count Primes in Ranges
- Program for Goldbach’s Conjecture (Two Primes with given Sum)
- Check if a number is sandwiched between primes
- Number of primes in a subarray (with updates)
- Check whether given three numbers are adjacent primes
- Sum of all Primes in a given range using Sieve of Eratosthenes
- Check if the sum of primes is divisible by any prime from the array
- Remove duplicates from an array of small primes
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.