#include <iostream>
using namespace std;
const int MAX = 1000000;
const int SIZE = 78500;
int P[SIZE];
bool isPrime(int num)
{
if (num == 2 || num == 3)
{
return true;
}
if (num % 6 != 1 && num % 6 != 5)
{
return false;
}
for (int i = 5; i*i <= num; i += 6)
{
if (num % i == 0 || num % (i+2) == 0)
{
return false;
}
}
return true;
}
int main()
{
int sum = -1;
int j = 0;
for(int i=2;i<MAX;i++)
if(isPrime(i))
P[j++] = i;
while(cin>>sum&&sum!=0)
{
int a = 0;
int i = P[a];
int j = sum-i;
while(i<=j)
{
if(isPrime(j))
{
cout<<sum<<" = "<<i<<" + "<<j<<endl;
break;
}
i = P[++a];
j = sum-i;
}
if(i>j)
cout<<"Goldbach's conjecture is wrong."<<endl;
}
return 0;
}
--------------------------------------
#include <iostream>
using namespace std;
const int MAX = 1000000;
const int SIZE = 78500;
bool IP[MAX];
int P[SIZE];
bool isPrime(int num)
{
if (num == 2 || num == 3)
{
return true;
}
if (num % 6 != 1 && num % 6 != 5)
{
return false;
}
for (int i = 5; i*i <= num; i += 6)
{
if (num % i == 0 || num % (i+2) == 0)
{
return false;
}
}
return true;
}
int main()
{
int sum = -1;
int j = 0;
for(int i=2;i<MAX;i++)
{
if(isPrime(i))
{
P[j++] = i;
IP[i] = 1;
}
else
IP[i] = 0;
}
while(cin>>sum&&sum!=0)
{
int a = 0;
int i = P[a];
int j = sum-i;
while(i<=j)
{
if(IP[j])
{
cout<<sum<<" = "<<i<<" + "<<j<<endl;
break;
}
i = P[++a];
j = sum-i;
}
if(i>j)
cout<<"Goldbach's conjecture is wrong."<<endl;
}
return 0;
}