For a given number check if it is prime or not. A prime number is a number which is only divisible by 1 and itself.
Input:
First line contains an integer, the number of test cases 'T'. Each test case should contain a positive integer N.
First line contains an integer, the number of test cases 'T'. Each test case should contain a positive integer N.
Output:
Print "Yes" if it is a prime number else print "No".
Constraints:
1<= T <=30
1<= N <=100
Example:
Input:
1
5
1
5
Output:
Yes
Yes
Your Code
#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int i, temp=1;
for(i=2; i<n/2; i++)
{
if(n%i==0)
{ temp=0;
break;
}
}
if(temp==1 && n!=1)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
}