给你一个n求出n由2个奇质因子的和 这2个因子差最大
没有就输出‘Goldbach‘s conjecture is wrong.
#include<stdio.h> #include<string.h> #include<algorithm> #include<vector> #include<math.h> using namespace std; #define MAXN 1000010 bool pri[MAXN]; int main() { memset(pri,0,sizeof(pri)); for(int i=2;i<=1000;i++) { if(!pri[i]) for(int j=i*i;j<=MAXN;j=j+i) pri[j]=1; } int n; while(scanf("%d",&n)!=EOF&&n) { int a=n/2,i; for(i=3;i<=a;i++) if(!pri[i]&&!pri[n-i]) { printf("%d = %d + %d\n",n,i,n-i); break; } if(i>a) printf("‘Goldbach‘s conjecture is wrong.\n"); } return 0; }
时间: 2024-10-26 14:56:37