the program should check if all even integers from low to high can be written as the sum of two prime numbers
the lower limit low will be greater than 2
the upper limit high will not exceed 10000
assume both inputs for low and high are even
if all even integers in the interval can be expressed as the sum of two primes, print "Verified". Otherwise, print "Failed".
I have written some functions which may be useful...
bool is_prime(int n){
for(int i = 2; i <= (n / 2); i++)
{if(n % i == 0) return false;}
return true;
}
int nxt_prime(int n){
if(is_prime(n)) return n;
return nxt_prime(++n);
}
I want to tackle the problem in:
take a test value (will loop it; low <= test <= high, each time increase test by 2)
break it down as n and test-n
first take n =2,
(**)
test if both n and test-n are prime
if not, take n to be the next prime
do (**)
could anyone help me in this?
i just spent tons of time on it
still can't the correct code....