Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CAN ANYBODY PLEASE HELP ME AND ANSWER THIS PROGRAM WITHIN THE NEXT HOUR???!! THI

ID: 3831707 • Letter: C

Question

CAN ANYBODY PLEASE HELP ME AND ANSWER THIS PROGRAM WITHIN THE NEXT HOUR???!! THIS IS MY PROGRAMMING WORK! PLEASE I NEED HELP! ANYONE!! SORRY THAT IT IS SIDEWAYS!

xam-V Your name, please PLEASE DOIwo OF THE THREE PROBLEMs BELow, AND INDICATE WHICH ONES YOU CHOOSE. DONOTDO ALL THREE. (1), Recall that the following boolean function primecheck (int n returns true or false depending on whether or not the integer n (which is assumed to be at least 2) is prime bool prime check int n0 int k 2; while (k sqrt(n) && n%k t 0) retum ksqrt(n); A very famous open question ofnumber theory, called Goldbach's conjecture, is whether or not every even number 6 or greater is the sum of two positive odd primes. (For example: 6 is the sum of 3 and 3; 8 is the sum of3 and 5; 10 is the sum of 3 and 7 and also the sum of 5 and 5, etc.) Write a C++ program which uses the above primecheckfunction to test Goldbach's conjecture. Specifically, your program should test every even numbernbetween 6 and 10,000 inclusive to see whether or not n can be written as the sum of two positive odd primes. Your output should look something like: 6-3+3 8 3+5 10 3+7 12 5+7 14-3+11 16 3+13 18m5+13 10000 59+9941 [Notes: If a number can be written in more than one way as a sum oftwo positive odd primes, you need output just one ofthe ways, i.e., the first you find. Also, ifit so bappens that a given n cannot be written as the sum of two positive odd primes, you should output a message to that effectl of course, this won't happen here Goldbach's conjecture has been tested by computer all the way up to huge values but let's assume we don't know this in advance]

Explanation / Answer

#include <iostream>
#include <cmath>

using namespace std;

bool primeCheck(int n)
{
int k = 2;
while(k <= sqrt(n) && n %k != 0)
k++;
return k > sqrt(n);
}

void checkGoldbach(int n)
{
if( n%2 != 0) n++;
for(int i = 6; i <= n; i += 2)
{
for(int j = 3; j<= n/2; j += 2)
{
if(primeCheck(j) && primeCheck(i-j))
{
cout << i << "="<<j<<"+"<<(i-j)<<endl;
break;
}
}
}
}

int main()
{

checkGoldbach(10000);
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote