Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int n;
- int main()
- {
- cout<<"Introduceti numarul pe care vreti sa il scrieti ca suma a doua numere prime: "; cin >> n;
- for (int i = 2;i <= n/2; i++)
- {
- int d;
- int nr = 0;
- for (d = 2; d <= i/2; d++)
- {
- if ( i % d == 0)
- nr++;
- }
- if (nr == 0)
- {
- int e = n - i;
- int j;
- int nr2 = 0;
- for(j = 2; j <= e/2; j++)
- {
- if(e % j == 0)
- nr2++;
- }
- if(nr2 == 0)
- {
- cout << i << " + "<< e <<endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement