Advertisement
Farjana_akter

Untitled

Feb 21st, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. bool mark[1000005]={false};
  4.  
  5. void sieve()
  6. {
  7. int i,j,k=0,isprime[10000];
  8. mark[0]=true;
  9. mark[1]=true;
  10. for(i=2;i*i<=1000000;i++)
  11. {
  12. if(mark[i]==false)
  13. {
  14. for(j=i*i;j<=1000000;j+=i)
  15. {
  16. mark[j]=true;
  17. }
  18. }
  19. }
  20. }
  21. int main()
  22. {
  23. sieve();
  24. int n,n1,ans1,ans,i;
  25. while(cin>>n)
  26. {
  27. if(n==0)
  28. break;
  29. bool flag=false;
  30. for(i=2;i<=n;i++)
  31. {
  32. if(mark[i]==false && mark[n-i]==false)
  33. {
  34. ans1=i;
  35. ans=n-i;
  36. flag=true;
  37. break;
  38. }
  39. }
  40. if(flag==false)
  41. cout<<"Goldbach's conjecture is wrong."<<endl;
  42. else
  43. cout<<n<<" = "<<ans1<<" + "<<ans<<endl;
  44. }
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement