The name of your C program file must be called goldbach.c, files with any other name will not be marked.
In June 7, 1742, Christian Goldbach wrote a letter to Leonhard Euler in which he states that "at least it seems that every number that is greater than 2 is the sum of three primes". Goldbach considered 1 to be a prime, a convention which is no longer assumed. Euler later came up with an equivalent "strong" conjecture which asserts that all positive even integers greater than two can be expressed as the sum of two primes. This conjecture remains open till today as nobody has yet proved it. In the words of Goldbach himself: "I consider an entirely certain theorem in spite of that I am not able to demonstrate it."
Your task is to write a program goldbach.c that accepts a number and determine all possible pairs of sum of primes, apart from rearrangement. You will need to explicitly check that the number input by the user is even, as well as, greater than two.
Assuming that the executable is goldbach, a sample run of the program is shown below. User input is denoted in bold.
$ gcc -Wall goldbach.c -o goldbach $ goldbach Enter even number: 2 2 is not an even number greater than 2 $ goldbach Enter even number: 3 3 is not an even number greater than 2 $ goldbach Enter even number: 4 4 = 2 + 2 $ goldbach Enter even number: 10 10 = 3 + 7 10 = 5 + 5 $ goldbach Enter even number: 50 50 = 3 + 47 50 = 7 + 43 50 = 13 + 37 50 = 19 + 31 $ goldbach Enter even number: 100 100 = 3 + 97 100 = 11 + 89 100 = 17 + 83 100 = 29 + 71 100 = 41 + 59 100 = 47 + 53 $ goldbach Enter even number: 1234 1234 = 3 + 1231 1234 = 5 + 1229 1234 = 11 + 1223 1234 = 17 + 1217 1234 = 41 + 1193 1234 = 47 + 1187 1234 = 53 + 1181 1234 = 71 + 1163 1234 = 83 + 1151 1234 = 131 + 1103 1234 = 137 + 1097 1234 = 173 + 1061 1234 = 251 + 983 1234 = 257 + 977 1234 = 263 + 971 1234 = 281 + 953 1234 = 293 + 941 1234 = 347 + 887 1234 = 353 + 881 1234 = 461 + 773 1234 = 491 + 743 1234 = 557 + 677 1234 = 587 + 647 1234 = 593 + 641 1234 = 617 + 617 $
A total of 23 different hosts have accessed this document in the last 445 days; your host, nsrp-source.comp.nus.edu.sg, has accessed it 6 times.
If you're interested, complete statistics for this document are also available, including breakdowns by top-level domain, host name, and date.