I didn't read your opening post carefully. So use your given function primecheck on every number from 2 to half of your even number N. When a prime number p is found, test if primecheck (N - p) returns true or not. Repeat this for all N from 1 to 10000.
Use k +=2 (since you are starting at k = 2), instead of k++ to speed it up.
Then, within that loop, put in another loop:
1 2 3 4 5 6 7 8 9
(forint i = 2; i < k /2; i++)
{
if (primecheck (i) && primecheck (k-i))
{
cout << i << " + " << k-i << " confirms GoldBach's conjecture for " << k << endl;
break;
}
}
cout << "Goldbach's conjecture is false! " << k << " is the first counterexample!" << endl; // this should never happen if you believe in the conjecture
You CAN NOT just do 5000. You have to check every combination of prime numbers, that's the whole point. If you really want to make it more efficient, put all the prime numbers into a vector or array. Then you can skip all the non-prime numbers on the sequential loops without any overhead at all.
You need another boolean flag to indicate whether to show "Goldbach's conjecture is false!" or not (bool nothingFound = true, set it to false when sum is found, display the above quote only if (nothingFound), reset it back to true before starting a new loop). To make it simple, just remove that line then. Then your above output is what you want.
But in case Goldbach's conjecture is false, your ideal solution should have that possible output (though you personally will never see it):