#include<stdio.h>
#include<math.h>
#include<cstring>
#define M 1000000
using namespace std;
void primeGenerate();
bool prime[M];
int main()
{
long n,i,g;
//freopen("in.txt","r",stdin);
primeGenerate();
while(scanf("%ld",&n)&&n)
{
g=0;
for(i=2;i<=n;i++)
if(prime[i] && prime[n-i])
{
g=1;
break;
}
if(g)
printf("%ld = %ld + %ld\n",n,i,n-i);
else
printf("Goldbach's conjecture is wrong.\n");
}
return 0;
}
void primeGenerate()
{
int i,j,m;
m=sqrt(M);
memset (prime,true,sizeof(prime)); //it set true in all array element.
prime[0]=prime[1]=false; //Because 0,1 not prime.
for(i=2;i<m;i++)
if(prime[i])
for(j=i+i;j<M;j+=i)
prime[j]=false;
}
No comments:
Post a Comment