-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprimarility test
63 lines (45 loc) · 1.24 KB
/
primarility test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Alice and Bob are meeting after a long time. As usual they love to play some math games. This times Alice takes the call and decides the game. The game is very simple, Alice says out an integer and Bob has to say whether the number is prime or not. Bob as usual knows the logic but since Alice doesn't give Bob much time to think, so Bob decides to write a computer program.
Help Bob accomplish this task by writing a computer program which will calculate whether the number is prime or not .
Input
The first line of the input contains an integer T, the number of testcases. T lines follow.
Each of the next T lines contains an integer N which has to be tested for primality.
Output
For each test case output in a separate line, "yes" if the number is prime else "no."
Constraints
1 ≤ T ≤ 20
1 ≤ N ≤ 100000
Sample Input 1
5
23
13
20
1000
99991
#include <iostream>
using namespace std;
int main() {
// your code goes here
int T;;
cin>>T;
while(T!=0)
{
int n;
cin>>n;
int count =0;
for(int i=1;i<=n;i++)
{
if(n%i==0)
{
count++;
}
}
if(count==2)
{
cout<<"yes"<<endl;
}
else
cout<<"no"<<endl;
T--;
}
return 0;
}