bool prim(int n){
int i;
bool p = true;
if (n < 2)
p = false;
else if (n != 2 && n%2 == 0)
p = false;
else for (i = 3;i*i <= n;i += 2)
if (n%i == 0)
p = false;
return p;
}
int i_prim(int n){
int a = n+1, b = n-1;
bool ok = false;
while (ok == false){
b++;
ok = prim(b);
}
ok = false;
while (ok == false){
a--;
ok = prim(a);
}
return b-a;
}