# Semi-Prime

Semi-Prime

Prime Number Definition
An integer greater than one is called a prime number if its only positive divisors (factors) are one and itself. For instance, 2, 11, 67, 89 are prime numbers but 8, 20, 27 are not.

Semi-Prime Number Definition
An integer greater than one is called a semi-prime number if it can be decompounded to TWO prime numbers. For example, 6 is a semi-prime number but 12 is not.

Your task is just to determinate whether a given number is a semi-prime number.

There are several test cases in the input. Each case contains a single integer N (2 <= N <= 1,000,000)

One line with a single integer for each case. If the number is a semi-prime number, then output "Yes", otherwise "No".

``````3
4
6
12``````

``````No
Yes
Yes
No``````

``````#include<stdio.h>
#include<math.h>
int main()
{
int prime(int);
int n;
while(scanf("%d",&n)!=EOF)
{
int i,t=sqrt(n),k=0,a;
if(prime(n))
printf("No\n");
else
{
for(i=2;i<=t;i++)
if(n%i==0)
{
k++;
a=i;
}
if(k>1)
printf("No\n");
else
if(prime(a) && prime(n/a))
printf("Yes\n");
else
printf("No\n");
}
}
return 0;
}
int prime(int n)
{
int i,t;
t=sqrt(n);
for(i=2;i<=t;i++)
if(n%i==0)
break;
if(i>t)
return 1;
return 0;
}``````

``````#include<stdio.h>
#include<math.h>
int main()
{
int prime(int);
int n;
while(scanf("%d",&n)!=EOF)
{
int i,t=sqrt(n),k=0,a;
if(prime(n))
printf("No\n");
else
{
for(i=2;i<=t;i++)
if(n%i==0)
{
k++;
a=i;
}
if(k>1)
printf("No\n");
else
if(prime(a) && prime(n/a))
printf("Yes\n");
else
printf("No\n");
}
}
return 0;
}
int prime(int n)
{
int i,t;
t=sqrt(n);
for(i=2;i<=t;i++)
if(n%i==0)
break;
if(i>t)
return 1;
return 0;
}``````