1. C++, Axel Fiedler

/*

* ACM Programming Contest

* Problem: 543 - Goldbach's Conjecture

* Status: Accepted

* Language: C++

* Runtime: 0.260

* Date: 2009-03-25 14:16:57

* Author: Axel Fiedler

*/
#include <cstdio>
#include <cmath>

bool prime(const int& n)
{
if (n == 2)
return true;

if (!(n & 1))
return false;

int limit = sqrt((long double)n);
for (int i = 3; i <= limit; i +=2)
if (n%i == 0)
return false;

return true;
}

int main()
{
int n;

scanf("%d", &n);
while (n > 0)
{
if ((n & 1) || (n < 6))
{
printf("Goldbach's conjecture is wrong.\n");
}
else
{
for (int i = 3; i <= n/2; i += 2)
{
if (prime(i) && prime(n - i))
{
printf("%d = %d + %d\n", n, i, n - i);
break;
}
}
}

scanf("%d", &n);
}

return 0;
}