Goldbach's conjecture in mathematics is that every even integer number greater than 2 can be expressed as the sum of two prime numbers. Write a program that prompts the user for a number, checks that it is positive and even, and prints the two primes that sum to it.

First I have a question: Is there a mistake? Maybe an even number adds up to 3 primes summed up or even more?

Then... Here's how far I've gotten:

#include <stdio.h>
#include <math.h>
int even (int number);
int prime (int number);
int
main ()
{
	int number, sum=0, divisor;
	printf ("Please enter a whole number: ");
	scanf ("%d", &number);
	if (number>=1)
	{
		prime (number);
	}
			
	return (0);
}

int even (int number)
{
	return (!(number%2));
}

int prime (int number)
{
	if (even (number))
	{

I've been stuck here for a while now...
Any hints would be appreciated!
Thank you in advance!

>I've been stuck here for a while now...
So basically you don't know how to calculate a prime number?

Basically yes... I know how to verify if it's even and positive. But I don't know how to check to see what 2 prime numbers add up to it.
I would need something like say
Entry= 12
then the program needs to say:
11+1=12

Start by working out a way of enumerating the prime numbers. If you don't know what the prime numbers below your entered number are, you can't solve the problem. Personally, I would probably create an array of primes to save myself the trouble of calculating them. However, you might want to calculate them, which reduces the current problem from "find two primes that add up to N" to "list all of the primes from 0 to N". That's a much more common problem that you can do research on.

Once you have the primes, it's not terribly difficult to walk over them, take the sum, and compare it with N.

> Maybe an even number adds up to 3 primes summed up or even more?
The sum of 3 odd numbers will always be odd, like the sum of two odd numbers will be even.
What you're suggesting is there are other primes which are even.

First I have a question: Is there a mistake? Maybe an even number adds up to 3 primes summed up or even more?

a mistake where? in Goldbach's Conjecture? if you've found a mistake there, get ready for publication in the journals.

an even number can only be the sum of three primes, if one of those primes is the number 2. which isn't saying anything that the Conjecture isn't already saying. because if you subtract 2 from each side of the equation, you have the original conjecture: "even numbers greater than 2 can be expressed as the sum of two prime numbers"

and i suppose an even number (greater than 6) can be expressed by the sum of four primes because every even number greater than 6 can be expressed as the sum of two even numbers greater than 2.

which brings us back full circle, back to Mr. Goldbach.

the point is that (as far as anyone has ever calculated) ALL even numbers >2 are the sum of two prime numbers.

4 = 2 + 2
6 = 3 + 3
8 = 5 + 3
10 = 5 + 5 or 7 + 3
12 = 5 + 7
14 = 7 + 7 or 11 + 3
16 = 11 + 5 or 13 + 3
18 = 13 + 5 or 11 + 7
20 = 13 + 7
22 = 17 + 5 or 11 + 11
24 = 17 + 7 or 13 + 11
26 = 19 + 7 or 13 + 13
28 = 23 + 5 or 17 + 11
30 = 23 + 7 or 17 + 13
32 = 29 + 3 or 19 + 13
34 = 17 + 17 or 29 + 5 or 31 + 3
36 = 19 + 17 or 29 + 7
38 = 19 + 19 or 31 + 7
40 = 23 + 17 or 29 + 11 or 37 + 3

etc.

I prolly missed a few. but you get the idear.


FYI, here's a tidy list of the first 1000 prime numbers:
http://primes.utm.edu/lists/small/1000.txt


.

This article has been dead for over six months. Start a new discussion instead.