WAP to find primorial of a number in java
Answers
Answer:
This program finds the Primorial of a given number.A primorial is also known as P-prime factorial.As factorial a Primorial is the product of all the prime numbers which are present from number till 1.It is denoted as P# of a number. Example- Primorial of 10 is 10#=7*5*3*2=210.
hope this will help you nd make sure to mark as brainlist dear
Primorial defined as the product of all prime numbers inferior or equal to n is a multiplication conditioned par a primality test of the numbers inferior or equal to n.
Example:
6 # = 2 × 3 × 5 = 30
Here is the WAP:
import java.util.Scanner;
class PrimorialNumber
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter number:");
int n = sc.nextInt(); int p=1;
for(int i=1;i<=n;i++)
{int f=0;
for(int j=2;j<=i/2;j++)
{
if(i%j == 0)
f=1;
break;
}
if(f==0)
p=p*i;
}
System.out.println("Primorial of no. is"+p);
}
}