Given a positive number N, the task is to check if N is a primorial prime number or not. Print ‘YES’ if N is a primorial prime number otherwise print ‘NO.
Primorial Prime: In Mathematics, A Primorial prime is a prime number of the form pn# + 1 or pn# – 1 , where pn# is the primorial of pn i.e the product of first n prime numbers.
Input : N = 5 Output : YES 5 is Primorial prime of the form pn - 1 for n=2, Primorial is 2*3 = 6 and 6-1 =5. Input : N = 31 Output : YES 31 is Primorial prime of the form pn + 1 for n=3, Primorial is 2*3*5 = 30 and 30+1 = 31.
The First few Primorial primes are:
2, 3, 5, 7, 29, 31, 211, 2309, 2311, 30029
- Generate all prime number in the range using Sieve of Eratosthenes.
- Check if n is prime or not, If n is not prime Then print No
- Else, starting from first prime (i.e 2 ) start multiplying next prime number and keep checking if product + 1 = n or product – 1 = n or not
- If either product+1=n or product-1=n, then n is a Primorial Prime Otherwise not.
Below is the implementation of above approach:
- Primorial of a number
- Check if a prime number can be expressed as sum of two Prime Numbers
- Check if a number is divisible by all prime divisors of another number
- Check if a number is Full Prime
- C Program to Check Whether a Number is Prime or not
- Check a number for Permutable Prime
- Check whether the given number is Wagstaff prime or not
- Check whether N is a Dihedral Prime Number or not
- Check if a number is Quartan Prime or not
- Check if a number is a Pythagorean Prime or not
- Check whether a number is circular prime or not
- Check if a number can be written as a sum of 'k' prime numbers
- Python program to check whether a number is Prime or not
- Check if the first and last digit of the smallest number forms a prime
- Check if LCM of array elements is divisible by a prime number or not
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.