Advertisement
fooker

N+M

Nov 20th, 2022
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. #define ll long long
  4. bool prime(ll x){
  5.   if (x==1) return false;
  6.   for (ll i=2; i*i<=x; i++){
  7.     if (x%i==0) return false;
  8.   }
  9.   return true;
  10. }
  11. int main()
  12. {
  13.    int t;
  14.    cin>>t;
  15.    while(t--){
  16.      ll n;
  17.      cin>>n;
  18.      ll m=2;
  19.      while(prime(n+m)==1){
  20.        m++;
  21.        while(prime(m)==0){
  22.          m++;
  23.        }
  24.      }
  25.      cout<<m<<"\n";
  26.    }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement