# Check if a number is primorial prime or not

Here given code implementation process.

``````// C program
// Check if a number is Primorial Prime or not
#include <stdio.h>

#define SIZE 1000001
//Check whether number is Primorial Prime or not
void is_primorial_prime(int collection[], int num)
{
//indicating the status of result prime number
int status = 0;
//Check that given number is greater than one and number is prime
if (num > 1 && collection[num] == 1)
{
int product = 1;
int i = 2;
while (status == 0 && i <= num && product <= num + 1)
{
if (collection[i] == 1)
{
//When i is prime
if (product + 1 == num || product - 1 == num)
{
status = 1;
}
else
{
product *= i;
}
}
i++;
}
}
if (status == 1)
{
printf("\n [%d] Is Primorial Prime", num);
}
else
{
printf("\n [%d] Is Not Primorial Prime", num);
}
}
//Find all prime numbers under 1000001
void sieve_of_eratosthenes(int collection[])
{
// Loop controlling variables
int i = 0;
int j = 1;
// Initial two numbers are not prime (0 and 1)
collection[i] = 0;
collection[j] = 0;
// Set the initial (2 to n element is prime)
for (i = 2; i < SIZE; ++i)
{
collection[i] = 1;
}
// Initial 0 and 1 are not prime
// We start to 2
for (i = 2; i * i < SIZE; ++i)
{
if (collection[i] == 1)
{
//When i is prime number
//Modify the prime status of all next multiplier of location i
for (j = i * i; j < SIZE; j += i)
{
collection[j] = 0;
}
}
}
}
int main()
{
//This is used to store prime number status
int collection[SIZE];
//Find find prime number
sieve_of_eratosthenes(collection);
//Test case
is_primorial_prime(collection, 7);
is_primorial_prime(collection, 107);
is_primorial_prime(collection, 13);
is_primorial_prime(collection, 1319);
is_primorial_prime(collection, 211);
is_primorial_prime(collection, 373);
is_primorial_prime(collection, 29);
return 0;
}``````

#### Output

``````  Is Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime``````
``````// Java program
// Check if a number is primorial prime or not
class PrimorialPrime
{
//Check whether number is Primorial Prime or not
public void is_primorial_prime(boolean[] collection, int num)
{
//indicating the status of result prime number
boolean status = false;
//Check that given number is greater than one and number is prime
if (num > 1 && collection[num] == true)
{
int product = 1;
int i = 2;
while (status == false && i <= num && product <= num + 1)
{
if (collection[i] == true)
{
//When i is prime
if (product + 1 == num || product - 1 == num)
{
status = true;
}
else
{
product *= i;
}
}
i++;
}
}
if (status == true)
{
System.out.print("\n [" + num + "] Is Primorial Prime");
}
else
{
System.out.print("\n [" + num + "] Is Not Primorial Prime");
}
}
//Find all prime numbers under 1000001
public void sieve_of_eratosthenes(boolean[] collection, int size)
{
// Loop controlling variables
int i = 0;
int j = 1;
// Initial two numbers are not prime (0 and 1)
collection[i] = false;
collection[j] = false;
// Set the initial (2 to n element is prime)
for (i = 2; i < size; ++i)
{
collection[i] = true;
}
// Initial 0 and 1 are not prime
// We start to 2
for (i = 2; i * i < size; ++i)
{
if (collection[i] == true)
{
//When i is prime number
//Modify the prime status of all next multiplier of location i
for (j = i * i; j < size; j += i)
{
collection[j] = false;
}
}
}
}
public static void main(String []args)
{
PrimorialPrime obj = new PrimorialPrime();
int size = 1000001;
//This is used to store prime number status
boolean[] collection = new boolean[size];
//Find find prime number
obj.sieve_of_eratosthenes(collection, size);
//Test case
obj.is_primorial_prime(collection, 7);
obj.is_primorial_prime(collection, 107);
obj.is_primorial_prime(collection, 13);
obj.is_primorial_prime(collection, 1319);
obj.is_primorial_prime(collection, 211);
obj.is_primorial_prime(collection, 373);
obj.is_primorial_prime(collection, 29);
}
}``````

#### Output

``````  Is Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime``````
``````//Include header file
#include <iostream>

using namespace std;
// C++ program
// Check if a number is primorial prime or not
class PrimorialPrime
{
public:
//Check whether number is Primorial Prime or not
void is_primorial_prime(bool collection[], int num)
{
//indicating the status of result prime number
bool status = false;
//Check that given number is greater than one and number is prime
if (num > 1 && collection[num] == true)
{
int product = 1;
int i = 2;
while (status == false && i <= num && product <= num + 1)
{
if (collection[i] == true)
{
//When i is prime
if (product + 1 == num || product - 1 == num)
{
status = true;
}
else
{
product *= i;
}
}
i++;
}
}
if (status == true)
{
cout << "\n [" << num << "] Is Primorial Prime";
}
else
{
cout << "\n [" << num << "] Is Not Primorial Prime";
}
}
//Find all prime numbers under 1000001
void sieve_of_eratosthenes(bool collection[], int size)
{
// Loop controlling variables
int i = 0;
int j = 1;
// Initial two numbers are not prime (0 and 1)
collection[i] = false;
collection[j] = false;
// Set the initial (2 to n element is prime)
for (i = 2; i < size; ++i)
{
collection[i] = true;
}
// Initial 0 and 1 are not prime
// We start to 2
for (i = 2; i *i < size; ++i)
{
if (collection[i] == true)
{
//When i is prime number
//Modify the prime status of all next multiplier of location i
for (j = i *i; j < size; j += i)
{
collection[j] = false;
}
}
}
}
};
int main()
{
PrimorialPrime obj = PrimorialPrime();
int size = 1000001;
//This is used to store prime number status
bool collection[size];
//Find find prime number
obj.sieve_of_eratosthenes(collection, size);
//Test case
obj.is_primorial_prime(collection, 7);
obj.is_primorial_prime(collection, 107);
obj.is_primorial_prime(collection, 13);
obj.is_primorial_prime(collection, 1319);
obj.is_primorial_prime(collection, 211);
obj.is_primorial_prime(collection, 373);
obj.is_primorial_prime(collection, 29);
return 0;
}``````

#### Output

``````  Is Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime``````
``````//Include namespace system
using System;

// C# program
// Check if a number is primorial prime or not

class PrimorialPrime
{
//Check whether number is Primorial Prime or not
public void is_primorial_prime(Boolean[] collection, int num)
{
//indicating the status of result prime number
Boolean status = false;
//Check that given number is greater than one and number is prime
if (num > 1 && collection[num] == true)
{
int product = 1;
int i = 2;
while (status == false && i <= num && product <= num + 1)
{
if (collection[i] == true)
{
//When i is prime
if (product + 1 == num || product - 1 == num)
{
status = true;
}
else
{
product *= i;
}
}
i++;
}
}
if (status == true)
{
Console.Write("\n [" + num + "] Is Primorial Prime");
}
else
{
Console.Write("\n [" + num + "] Is Not Primorial Prime");
}
}
//Find all prime numbers under 1000001
public void sieve_of_eratosthenes(Boolean[] collection, int size)
{
// Loop controlling variables
int i = 0;
int j = 1;
// Initial two numbers are not prime (0 and 1)
collection[i] = false;
collection[j] = false;
// Set the initial (2 to n element is prime)
for (i = 2; i < size; ++i)
{
collection[i] = true;
}
// Initial 0 and 1 are not prime
// We start to 2
for (i = 2; i * i < size; ++i)
{
if (collection[i] == true)
{
//When i is prime number
//Modify the prime status of all next multiplier of location i
for (j = i * i; j < size; j += i)
{
collection[j] = false;
}
}
}
}
public static void Main(String[] args)
{
PrimorialPrime obj = new PrimorialPrime();
int size = 1000001;
//This is used to store prime number status
Boolean[] collection = new Boolean[size];
//Find find prime number
obj.sieve_of_eratosthenes(collection, size);
//Test case
obj.is_primorial_prime(collection, 7);
obj.is_primorial_prime(collection, 107);
obj.is_primorial_prime(collection, 13);
obj.is_primorial_prime(collection, 1319);
obj.is_primorial_prime(collection, 211);
obj.is_primorial_prime(collection, 373);
obj.is_primorial_prime(collection, 29);
}
}``````

#### Output

``````  Is Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime``````
``````<?php
// Php porgram
// Check if a number is primorial prime or not
class PrimorialPrime
{
//Check whether number is Primorial Prime or not
public  function is_primorial_prime( & \$collection, \$num)
{
//indicating the status of result prime number
\$status = false;
//Check that given number is greater than one and number is prime
if (\$num > 1 && \$collection[\$num] == true)
{
\$product = 1;
\$i = 2;
while (\$status == false && \$i <= \$num && \$product <= \$num + 1)
{
if (\$collection[\$i] == true)
{
//When i is prime
if (\$product + 1 == \$num || \$product - 1 == \$num)
{
\$status = true;
}
else
{
\$product *= \$i;
}
}
\$i++;
}
}
if (\$status == true)
{
echo "\n [". \$num ."] Is Primorial Prime";
}
else
{
echo "\n [". \$num ."] Is Not Primorial Prime";
}
}
//Find all prime numbers under 1000001
public  function sieve_of_eratosthenes( & \$collection, \$size)
{
// Loop controlling variables
\$i = 0;
\$j = 1;
// Initial two numbers are not prime (0 and 1)
\$collection[\$i] = false;
\$collection[\$j] = false;
// Initial 0 and 1 are not prime
// We start to 2
for (\$i = 2; \$i * \$i < \$size; ++\$i)
{
if (\$collection[\$i] == true)
{
//When i is prime number
//Modify the prime status of all next multiplier of location i
for (\$j = \$i * \$i; \$j < \$size; \$j += \$i)
{
\$collection[\$j] = false;
}
}
}
}
}

function main()
{
\$obj = new PrimorialPrime();
\$size = 1000001;
//This is used to store prime number status
\$collection = array_fill(0, \$size, true);
//Find find prime number
\$obj->sieve_of_eratosthenes(\$collection, \$size);
//Test case
\$obj->is_primorial_prime(\$collection, 7);
\$obj->is_primorial_prime(\$collection, 107);
\$obj->is_primorial_prime(\$collection, 13);
\$obj->is_primorial_prime(\$collection, 1319);
\$obj->is_primorial_prime(\$collection, 211);
\$obj->is_primorial_prime(\$collection, 373);
\$obj->is_primorial_prime(\$collection, 29);
}
main();``````

#### Output

``````  Is Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime``````
``````// Node Js program
// Check if a number is primorial prime or not
class PrimorialPrime
{
//Check whether number is Primorial Prime or not
is_primorial_prime(collection, num)
{
//indicating the status of result prime number
var status = false;
//Check that given number is greater than one and number is prime
if (num > 1 && collection[num] == true)
{
var product = 1;
var i = 2;
while (status == false && i <= num && product <= num + 1)
{
if (collection[i] == true)
{
//When i is prime
if (product + 1 == num || product - 1 == num)
{
status = true;
}
else
{
product *= i;
}
}
i++;
}
}
if (status == true)
{
process.stdout.write("\n [" + num + "] Is Primorial Prime");
}
else
{
process.stdout.write("\n [" + num + "] Is Not Primorial Prime");
}
}
//Find all prime numbers under 1000001
sieve_of_eratosthenes(collection, size)
{
// Loop controlling variables
var i = 0;
var j = 1;
// Initial two numbers are not prime (0 and 1)
collection[i] = false;
collection[j] = false;
// Set the initial (2 to n element is prime)
for (i = 2; i < size; ++i)
{
collection[i] = true;
}
// Initial 0 and 1 are not prime
// We start to 2
for (i = 2; i * i < size; ++i)
{
if (collection[i] == true)
{
//When i is prime number
//Modify the prime status of all next multiplier of location i
for (j = i * i; j < size; j += i)
{
collection[j] = false;
}
}
}
}
}

function main()
{
var obj = new PrimorialPrime();
var size = 1000001;
//This is used to store prime number status
var collection = Array(size).fill(false);
//Find find prime number
obj.sieve_of_eratosthenes(collection, size);
//Test case
obj.is_primorial_prime(collection, 7);
obj.is_primorial_prime(collection, 107);
obj.is_primorial_prime(collection, 13);
obj.is_primorial_prime(collection, 1319);
obj.is_primorial_prime(collection, 211);
obj.is_primorial_prime(collection, 373);
obj.is_primorial_prime(collection, 29);
}
main();``````

#### Output

``````  Is Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime``````
``````#  Python 3 program
#  Check if a number is primorial prime or not
class PrimorialPrime :
# Check whether number is Primorial Prime or not
def is_primorial_prime(self, collection, num) :
# indicating the status of result prime number
status = False
# Check that given number is greater than one and number is prime
if (num > 1 and collection[num] == True) :
product = 1
i = 2
while (status == False and i <= num and product <= num + 1) :
if (collection[i] == True) :
# When i is prime
if (product + 1 == num or product - 1 == num) :
status = True
else :
product *= i

i += 1

if (status == True) :
print("\n [{0}] Is Primorial Prime".format(num), end = "")
else :
print("\n [{0}] Is Not Primorial Prime".format(num), end = "")

# Find all prime numbers under 1000001
def sieve_of_eratosthenes(self, collection, size) :
#  Loop controlling variables
i = 0
j = 1
#  Initial two numbers are not prime (0 and 1)
collection[i] = False
collection[j] = False
#  Initial 0 and 1 are not prime
#  We start to 2
i = 2
while (i * i < size) :
if (collection[i] == True) :
# When i is prime number
# Modify the prime status of all next multiplier of location i
j = i * i
while (j < size) :
collection[j] = False
j += i

i += 1

def main() :
obj = PrimorialPrime()
size = 1000001
# This is used to store prime number status
collection = [True] * (size)
# Find find prime number
obj.sieve_of_eratosthenes(collection, size)
# Test case
obj.is_primorial_prime(collection, 7)
obj.is_primorial_prime(collection, 107)
obj.is_primorial_prime(collection, 13)
obj.is_primorial_prime(collection, 1319)
obj.is_primorial_prime(collection, 211)
obj.is_primorial_prime(collection, 373)
obj.is_primorial_prime(collection, 29)

if __name__ == "__main__": main()``````

#### Output

``````  Is Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime``````
``````#  Ruby program
#  Check if a number is primorial prime or not
class PrimorialPrime
# Check whether number is Primorial Prime or not
def is_primorial_prime(collection, num)
# indicating the status of result prime number
status = false
# Check that given number is greater than one and number is prime
if (num > 1 && collection[num] == true)
product = 1
i = 2
while (status == false && i <= num && product <= num + 1)
if (collection[i] == true)
# When i is prime
if (product + 1 == num || product - 1 == num)
status = true
else
product *= i
end

end

i += 1
end

end

if (status == true)
print("\n [", num ,"] Is Primorial Prime")
else
print("\n [", num ,"] Is Not Primorial Prime")
end

end

# Find all prime numbers under 1000001
def sieve_of_eratosthenes(collection, size)
#  Loop controlling variables
i = 0
j = 1
#  Initial two numbers are not prime (0 and 1)
collection[i] = false
collection[j] = false
#  Initial 0 and 1 are not prime
#  We start to 2
i = 2
while (i * i < size)
if (collection[i] == true)
# When i is prime number
# Modify the prime status of all next multiplier of location i
j = i * i
while (j < size)
collection[j] = false
j += i
end

end

i += 1
end

end

end

def main()
obj = PrimorialPrime.new()
size = 1000001
# This is used to store prime number status
collection = Array.new(size) {true}
# Find find prime number
obj.sieve_of_eratosthenes(collection, size)
# Test case
obj.is_primorial_prime(collection, 7)
obj.is_primorial_prime(collection, 107)
obj.is_primorial_prime(collection, 13)
obj.is_primorial_prime(collection, 1319)
obj.is_primorial_prime(collection, 211)
obj.is_primorial_prime(collection, 373)
obj.is_primorial_prime(collection, 29)
end

main()``````

#### Output

``````  Is Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime``````
``````// Scala program
// Check if a number is primorial prime or not
class PrimorialPrime
{
//Check whether number is Primorial Prime or not
def is_primorial_prime(collection: Array[Boolean], num: Int): Unit = {
//indicating the status of result prime number
var status: Boolean = false;
//Check that given number is greater than one and number is prime
if (num > 1 && collection(num) == true)
{
var product: Int = 1;
var i: Int = 2;
while (status == false && i <= num && product <= num + 1)
{
if (collection(i) == true)
{
//When i is prime
if (product + 1 == num || product - 1 == num)
{
status = true;
}
else
{
product *= i;
}
}
i += 1;
}
}
if (status == true)
{
print("\n [" + num + "] Is Primorial Prime");
}
else
{
print("\n [" + num + "] Is Not Primorial Prime");
}
}
//Find all prime numbers under 1000001
def sieve_of_eratosthenes(collection: Array[Boolean], size: Int): Unit = {
// Loop controlling variables
var i: Int = 0;
var j: Int = 1;
// Initial two numbers are not prime (0 and 1)
collection(i) = false;
collection(j) = false;
// Initial 0 and 1 are not prime
// We start to 2
i = 2;
while (i * i < size)
{
if (collection(i) == true)
{
//When i is prime number
//Modify the prime status of all next multiplier of location i
j = i * i;
while (j < size)
{
collection(j) = false;
j += i;
}
}
i += 1;
}
}
}
object Main
{
def main(args: Array[String]): Unit = {
var obj: PrimorialPrime = new PrimorialPrime();
var size: Int = 1000001;
//This is used to store prime number status
var collection: Array[Boolean] = Array.fill[Boolean](size)(true);
//Find find prime number
obj.sieve_of_eratosthenes(collection, size);
//Test case
obj.is_primorial_prime(collection, 7);
obj.is_primorial_prime(collection, 107);
obj.is_primorial_prime(collection, 13);
obj.is_primorial_prime(collection, 1319);
obj.is_primorial_prime(collection, 211);
obj.is_primorial_prime(collection, 373);
obj.is_primorial_prime(collection, 29);
}
}``````

#### Output

``````  Is Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime``````
``````// Swift 4 program
// Check if a number is primorial prime or not
class PrimorialPrime
{
//Check whether number is Primorial Prime or not
func is_primorial_prime(_ collection: [Bool], _ num: Int)
{
//indicating the status of result prime number
var status: Bool = false;
//Check that given number is greater than one and number is prime
if (num > 1 && collection[num] == true)
{
var product: Int = 1;
var i: Int = 2;
while (status == false && i <= num && product <= num + 1)
{
if (collection[i] == true)
{
//When i is prime
if (product + 1 == num || product - 1 == num)
{
status = true;
}
else
{
product *= i;
}
}
i += 1;
}
}
if (status == true)
{
print("\n [\(num)] Is Primorial Prime", terminator: "");
}
else
{
print("\n [\(num)] Is Not Primorial Prime", terminator: "");
}
}
//Find all prime numbers under 1000001
func sieve_of_eratosthenes(_ collection: inout[Bool], _ size: Int)
{
// Loop controlling variables
var i: Int = 0;
var j: Int = 1;
// Initial two numbers are not prime (0 and 1)
collection[i] = false;
collection[j] = false;
// Initial 0 and 1 are not prime
// We start to 2
i = 2;
while (i * i < size)
{
if (collection[i] == true)
{
//When i is prime number
//Modify the prime status of all next multiplier of location i
j = i * i;
while (j < size)
{
collection[j] = false;
j += i;
}
}
i += 1;
}
}
}
func main()
{
let obj: PrimorialPrime = PrimorialPrime();
let size: Int = 1000001;
//This is used to store prime number status
var collection: [Bool] = Array(repeating: true, count: size);
//Find find prime number
obj.sieve_of_eratosthenes(&collection, size);
//Test case
obj.is_primorial_prime(collection, 7);
obj.is_primorial_prime(collection, 107);
obj.is_primorial_prime(collection, 13);
obj.is_primorial_prime(collection, 1319);
obj.is_primorial_prime(collection, 211);
obj.is_primorial_prime(collection, 373);
obj.is_primorial_prime(collection, 29);
}
main();``````

#### Output

``````  Is Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime
 Is Not Primorial Prime
 Is Primorial Prime``````

## Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.