Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- bool mark[1000005]={false};
- void sieve()
- {
- int i,j,k=0,isprime[10000];
- mark[0]=true;
- mark[1]=true;
- for(i=2;i*i<=1000000;i++)
- {
- if(mark[i]==false)
- {
- for(j=i*i;j<=1000000;j+=i)
- {
- mark[j]=true;
- }
- }
- }
- }
- int main()
- {
- sieve();
- int n,n1,ans1,ans,i;
- while(cin>>n)
- {
- if(n==0)
- break;
- bool flag=false;
- for(i=2;i<=n;i++)
- {
- if(mark[i]==false && mark[n-i]==false)
- {
- ans1=i;
- ans=n-i;
- flag=true;
- break;
- }
- }
- if(flag==false)
- cout<<"Goldbach's conjecture is wrong."<<endl;
- else
- cout<<n<<" = "<<ans1<<" + "<<ans<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement