0

Hi guys,

I'm working on a program that has to do with Goldbach's second conjecture (any even number larger than 5 can be expressed as the sum of three prime numbers). I have to write a program that takes integer *n* (larger than or equal to 6) and finds three prime numbers p1, p2 and p3. The equation result is n = p1+p2+p3 and I have to find all possible combinations of said primes as well.

I've written somewhat of a code so far, can anyone help me with this problem? It would be greatly appreciated. Thanks guys :)

```
// goldbach2.cpp
// Author : Elspeth Eastman
// March 18th, 2008
#include <iostream>
using namespace std;
bool is_prime (int); // letting compiler know about the certain function
#include <cmath>
void main (void)
{
int n; // the even number
int p1, p2, p3; // the two prime numbers
int prime = is_prime(n);
p1=n;
p2=2;
p3=n+2;
cout << "Enter an even integer number (larger than 5) : ";
cin >> n;
for (p1=2; p1<=n; p1++) // for statement repeatedly checks p1 until it is true
{((p1!=n) && !(p1/=n)); // checks whether the numbers are prime
cout << n << " = " << is_prime(p1) << " + " << is_prime(n-p1) << is_prime(p3) << endl;//displays the end result of two prime numbers
}
}
bool is_prime (int x) // declaring the functions
{
int num;
if (!(x%2)) // check whether or not x is even
{
return (x==2);
}
for (num=3; num<x; num++)
{
if (!(x % num))
return 0;
}
return 1;
}
```