-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPRIME1.cpp
More file actions
43 lines (41 loc) · 714 Bytes
/
PRIME1.cpp
File metadata and controls
43 lines (41 loc) · 714 Bytes
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
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
//#include <math>
#include <math.h>
using namespace std;
int PrimeTest(long x)
{
long b = 2;
while (b <= sqrt(x))
{
if (x % b == 0)
{
int Answer = 0;
return Answer;
}
b++;
}
int Answer = 1;
return Answer;
}
int main()
{
int test;
cin>>test;
while(test--)
{
long a,b,i;
cin>>a>>b;
//cout<<a<<b<<endl;
for(i=a;i<=b;i++)
{
if (PrimeTest(i)&&(i!=1))
cout << i<<endl;
}
cout<<endl;
}
return 0;
}