Write a program to check if the input is a SPHENIC NUMBER.


Sphenic numbers are numbers which have exactly 3 factors, all prime. A Sphenic number has exactly 8 divisors.
The smallest sphenic number is 30 = 2 × 3 × 5, the product of the smallest three primes. The first few sphenic numbers are:

30, 42, 66, 70, 78, 102, 105, 110, 114, 130, 138, 154, 165, ...

import java.util.*;

public class SphenicNumber {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t,count=0,prd=1;
System.out.println("Enter a number : ");
int num =sc.nextInt();
t=num;
for(int i=1;i<=t;i++)
{
if(t%i==0)
count++;
}
if(count==8)
{
for(int i=1;i<=num;i++)
{
for(int j=1;j<=i;i++)
{
if(t%i==0)
{
if(i%j==0)
{
prd*=i;
if(prd==num)
break;
}
}
}
System.out.println("YES");
}
}
else
System.out.println("NO");
}
}

FOR CODE : CLICK >> https://onecompiler.com/java/3yju3876b TO FIND OUTPUT

SUPPORT US >> https://onethoughttechnology.blogspot.com (OFFICIAL WEBSITE)