#include <stdio.h>
int isprime(int n)
{
int i;
if (n % 2 == 0) {
return n == 2;
}
for (i = 3; i * i <= n; i += 2) {
if (n % i == 0) {
return 0;
}
}
return 1;
}
int main()
{
int prime[20];
int p;
int i;
p = 0;
for (i = 2; p < 20; i++) {
if (isprime(i)) {
prime[p++] = i;
}
}
for (p = 0; p < 20; p++) {
printf("%2d %d\n", p
+ 1, prime
[p
]); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgaXNwcmltZShpbnQgbikKewoJaW50CWk7CgoJaWYgKG4gJSAyID09IDApIHsKCQlyZXR1cm4gbiA9PSAyOwoJfQoJZm9yIChpID0gMzsgaSAqIGkgPD0gbjsgaSArPSAyKSB7CgkJaWYgKG4gJSBpID09IDApIHsKCQkJcmV0dXJuIDA7CgkJfQoJfQoJcmV0dXJuIDE7Cn0KCmludCBtYWluKCkKewoJaW50CXByaW1lWzIwXTsKCWludAlwOwoJaW50CWk7CgoJcCA9IDA7Cglmb3IgKGkgPSAyOyBwIDwgMjA7IGkrKykgewoJCWlmIChpc3ByaW1lKGkpKSB7CgkJCXByaW1lW3ArK10gPSBpOwoJCX0KCX0KCWZvciAocCA9IDA7IHAgPCAyMDsgcCsrKSB7CgkJcHJpbnRmKCIlMmQgJWRcbiIsIHAgKyAxLCBwcmltZVtwXSk7Cgl9CglyZXR1cm4gMDsKfQo=