In: Computer Science
Project #1. Goldbach Conjecture.
“Every even integer greater than 2 can be represented as the sum of two prime numbers.”
For this project show the sums from 100,000 to 100,200.
(1) Print it as follows:
100,000 prime no. 1prime no. 2
100,002……
100,004……
………
………
100,200……
(Of course, if you find that there is no such pair of primes, indicate the first number that does have a Goldbach pair. I don’t think you’ll find such a number!)
(2) Also, print out the source code (hopefully well documented).
SOURCE CODE
#include<bits/stdc++.h>
using namespace std;
void prime(int n, bool isPrime[]) // to find all the numbers
upto n prime or not
{
  
   isPrime[0] = isPrime[1] = false;
   for (int i=2; i<=n; i++)
       isPrime[i] = true;
   for (int p=2; p*p<=n; p++)
   {
      
       if (isPrime[p] == true)
       {
          
           for (int i=p*p;
i<=n; i += p)
          
    isPrime[i] = false;
       }
   }
}
void findPrimePair(int n)
{
   bool isPrime[n+1]; // to srote all number upto n prime
or not
   prime(n, isPrime);
   for (int i=0; i<n; i++)
   {
       if (isPrime[i] &&
isPrime[n-i])
       {
           cout << n
<< "\t"<< i << "\t\t" << (n-i)
<<"\n";
           return;
       }
   }
}
int main()
{    int i = 100000;
   cout << "Number\t" << "Prime Number 1\t"
<< "Prime Number 2\t"<<"\n";
   while(i<=100200)
   findPrimePair(i++);
   return 0;
}
OUTPUT
Number   Prime Number 1   Prime Number
2  
100000   11       99989
100002   11       99991
100004   13       99991
100005   2       100003
100006   3       100003
100008   5       100003
100010   7       100003
100012   23       99989
100014   11       100003
100016   13       100003
100018   29       99989
100020   17       100003
100021   2       100019
100022   3       100019
100024   5       100019
100026   7       100019
100028   37       99991
100030   11       100019
100032   13       100019
100034   31       100003
100036   17       100019
100038   19       100019
100040   37       100003
100042   23       100019
100044   41       100003
100045   2       100043
100046   3       100043
100048   5       100043
100050   7       100043
100051   2       100049
100052   3       100049
100054   5       100049
100056   7       100049
100058   67       99991
100059   2       100057
100060   3       100057
100062   5       100057
100064   7       100057
100066   17       100049
100068   11       100057
100070   13       100057
100071   2       100069
100072   3       100069
100074   5       100069
100076   7       100069
100078   29       100049
100080   11       100069
100082   13       100069
100084   41       100043
100086   17       100069
100088   19       100069
100090   41       100049
100092   23       100069
100094   37       100057
100096   47       100049
100098   29       100069
100100   31       100069
100102   53       100049
100104   47       100057
100105   2       100103
100106   3       100103
100108   5       100103
100110   7       100103
100111   2       100109
100112   3       100109
100114   5       100109
100116   7       100109
100118   61       100057
100120   11       100109
100122   13       100109
100124   67       100057
100126   17       100109
100128   19       100109
100130   61       100069
100131   2       100129
100132   3       100129
100134   5       100129
100136   7       100129
100138   29       100109
100140   11       100129
100142   13       100129
100144   41       100103
100146   17       100129
100148   19       100129
100150   41       100109
100152   23       100129
100153   2       100151
100154   3       100151
100155   2       100153
100156   3       100153
100158   5       100153
100160   7       100153
100162   11       100151
100164   11       100153
100166   13       100153
100168   17       100151
100170   17       100153
100171   2       100169
100172   3       100169
100174   5       100169
100176   7       100169
100178   109       100069
100180   11       100169
100182   13       100169
100184   31       100153
100185   2       100183
100186   3       100183
100188   5       100183
100190   7       100183
100191   2       100189
100192   3       100189
100194   5       100189
100195   2       100193
100196   3       100193
100198   5       100193
100200   7      
100193
SCREENSHOT

please give a upvote if u fell helpful.