You are viewing a single comment's thread. Return to all comments →
bool is_prime(int n){
for (int i= 2; i<=sqrt(n); i++) if(n%i == 0) return false; return true;
} int rec(int s){
int n = 1; int count = 0; while (s-2*n*n > 1) { int num = s-2*n*n; if(is_prime(num)==true) count++; n++; } return count;
} int main() {
int t; scanf("%d",&t); while (t--) { int n; scanf("%d",&n); printf("%d\n",rec(n)); } return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #46: Goldbach's other conjecture
You are viewing a single comment's thread. Return to all comments →
code in c:
bool is_prime(int n){
} int rec(int s){
} int main() {
}