# POJ 2262 Goldbach's Conjecture（数论）

Description

Input

Output

Sample Input
8
20
42
0
Sample Output
8 = 3 + 5
20 = 3 + 17
42 = 5 + 37
Solution

Code

#include<stdio.h>
#define MAX 1000001
int prime[MAX]={0};
void sushu()//打表
{
int i,j;
for(i=2;i<MAX;i++)
if(!prime[i])
for(j=2;i*j<MAX;j++)
prime[j*i]=1;
prime[0] = prime[1] = 1;
}
int main()
{
int n,i;
sushu();
while (scanf("%d",&n)==1,n)
{
for(i=3;i<=n/2;i+=2)//枚举
if(prime[i]==0&&prime[n-i]==0)//找到可行解
{
printf("%d = %d + %d\n", n, i, n-i);//按格式输出
break;
}
if(i>n/2)//不存在符合条件的质数
printf("Goldbach's conjecture is wrong.\n");
}
return 0;
}

#### POJ 2262 Goldbach's Conjecture(哥德巴赫猜想)

2015-08-13 22:29:33

#### POJ2262-Goldbach's Conjecture

2011-07-29 01:57:56

#### LightOJ 1259 - Goldbach`s Conjecture （分解偶数为两个素数之和）

2016-03-08 17:43:06

#### POJ2909_Goldbach's Conjecture【素数判断】【水题】

2014-09-24 09:01:44

#### poj2262-Goldbach's Conjecture

2013-06-06 13:31:33

#### hdu 1397 Goldbach's Conjecture

2014-12-05 13:13:38

#### 九度OJ-1440：Goldbach's Conjecture

2017-02-05 15:00:32

#### 1397.Goldbach's Conjecture

2016-12-07 18:09:44

#### POJ 2262 Goldbach's Conjecture 数论

2011-09-09 20:45:12

#### POJ 2262 Goldbach’s Conjecture

2010-06-30 22:52:00