Skip to content

Instantly share code, notes, and snippets.

@completejavascript
Created September 15, 2018 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save completejavascript/330374b8faae79219d23d31028daf919 to your computer and use it in GitHub Desktop.
Save completejavascript/330374b8faae79219d23d31028daf919 to your computer and use it in GitHub Desktop.
#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