Showing posts with label primorial-of-number. Show all posts
Showing posts with label primorial-of-number. Show all posts

Monday, July 6, 2020

Write a program to input a number and find the Primorial of this number? (6= 2, 3, 5 =2*3*5=30)

42)   Write a program to input a number and find the Primorial of this number? (6= 2, 3, 5        à2*3*5=30)

import java.util.*;
public class Primorial
{
   public static void main(String args[ ])
   {
      Scanner sc = new Scanner (System.in);
      System.out.println("Enter a number");
      int a = sc.nextInt();
      int p=1;
      for(int i=2;i<=a;i++)
      {
        int c = 0;
        for(int j=1;j<=i;j++)
        {
            if(i%j==0)
            c++;
        }
        if(c==2)
        {
            p = p*i;
        }                 
      }
      System.out.println("PRIMORIAL of "+a+" = "+p);
    }
}

output :  


 jhvghvgk ;nkjn ,nkjhj