#include <iostream>
using namespace std;
int getClosestPrime(int inputNum){
bool isPrime = false;
inputNum++;
while (!isPrime){
for (int i = 2; i <= inputNum/2; i++){
if (inputNum % i == 0){
isPrime = false;
break; //if at any time found it's not a prime, break the for loop
}
isPrime = true;
}
if (isPrime == false){
inputNum++;
} else {
return inputNum;
}
}
}
int main()
{
int a = getClosestPrime(1258);
cout <<"1259?"<<endl;
cout <<a<<endl;
a = getClosestPrime(1259);
cout <<"1277?"<<endl;
cout <<a;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBnZXRDbG9zZXN0UHJpbWUoaW50IGlucHV0TnVtKXsKICAgIGJvb2wgaXNQcmltZSA9IGZhbHNlOwogICAgaW5wdXROdW0rKzsKICAgIHdoaWxlICghaXNQcmltZSl7CiAgICAgICAgZm9yIChpbnQgaSA9IDI7IGkgPD0gaW5wdXROdW0vMjsgaSsrKXsKICAgICAgICAgICAgaWYgKGlucHV0TnVtICUgaSA9PSAwKXsKICAgICAgICAgICAgICAgIGlzUHJpbWUgPSBmYWxzZTsKICAgICAgICAgICAgICAgIGJyZWFrOyAvL2lmIGF0IGFueSB0aW1lIGZvdW5kIGl0J3Mgbm90IGEgcHJpbWUsIGJyZWFrIHRoZSBmb3IgbG9vcAogICAgICAgICAgICB9CiAgICAgICAgICAgIGlzUHJpbWUgPSB0cnVlOwogICAgICAgIH0KICAgICAgICBpZiAoaXNQcmltZSA9PSBmYWxzZSl7CiAgICAgICAgICAgIGlucHV0TnVtKys7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcmV0dXJuIGlucHV0TnVtOwogICAgICAgIH0KICAgIH0KfQoKaW50IG1haW4oKQp7CiAgICBpbnQgYSA9IGdldENsb3Nlc3RQcmltZSgxMjU4KTsKICAgIGNvdXQgPDwiMTI1OT8iPDxlbmRsOwogICAgY291dCA8PGE8PGVuZGw7CiAgICBhID0gZ2V0Q2xvc2VzdFByaW1lKDEyNTkpOwogICAgY291dCA8PCIxMjc3PyI8PGVuZGw7CiAgICBjb3V0IDw8YTsKfQo=