满足条件的数abc其实非常少,最多可能只有50个,去掉合数,只有十个左右.b + c - 10 = a或b+c=a
c = 1, 3, 5, 7, 9b = 0-9可以算出a小于33的质数,2,3,5,7,11,13,17,19,23,29,31
int isprime(int x) {
int i;
int const t[10] = {3,5,7,11,13,17,19,23,29,31};
for (i = 0; i < 10; ++i) {
if (x % t[i] == 0) return 0;
}
return 1;
}
int main() {
int a, b, c, x;
for ( b = 0; b < 10; ++b) {
for ( c = 1; c < 10; c += 2) {
a = (b + c < 10) ? b + c : b + c - 10;
x = a * 100 + b * 10 + c;
if (a > 0 isprime(x)) {
printf("%d ", x);
}
}
}
}