Created
September 15, 2018 07:59
-
-
Save completejavascript/330374b8faae79219d23d31028daf919 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
bool isPrime(int a) | |
{ | |
if(a == 0 || a == 1) return false; | |
if(a == 2) return true; | |
for(int i = 2; i*i <= a; i++) | |
if(a % i == 0) | |
return false; | |
return true; | |
} | |
int main() | |
{ | |
ios::sync_with_stdio(false); | |
freopen("input.txt","r",stdin); | |
int T, M, N; | |
cin >> T; | |
for(int tc = 0; tc < T; tc++) | |
{ | |
cin >> M >> N; | |
for(int i = M; i <= N; i++) | |
if(isPrime(i)) cout << i << endl; | |
cout << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment