Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int n, i;
- bool flag = false;
- cout << "Enter a positive integer: ";
- cin >> n;
- for(i = 2; i <= n/2; ++i)
- {
- if (checkPrime(i))
- {
- if (checkPrime(n - i))
- {
- cout << n << " = " << i << " + " << n-i << endl;
- flag = true;
- }
- }
- }
- if (!flag)
- cout << n << " can't be expressed as sum of two prime numbers.";
- return 0;
- bool isPrime = true;
- for(i = 2; i <= n/2; ++i)
- {
- if(n % i == 0)
- {
- isPrime = false;
- break;
- }
- }
- return isPrime;
Add Comment
Please, Sign In to add comment