Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define ll long long
- bool prime(ll x){
- if (x==1) return false;
- for (ll i=2; i*i<=x; i++){
- if (x%i==0) return false;
- }
- return true;
- }
- int main()
- {
- int t;
- cin>>t;
- while(t--){
- ll n;
- cin>>n;
- ll m=2;
- while(prime(n+m)==1){
- m++;
- while(prime(m)==0){
- m++;
- }
- }
- cout<<m<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement