In 1742, a German amateur mathematician named Christian Goldbach wrote
to Leonhard Euler with the following conjecture:
Every number greater than 2 can be written as the sum of three
prime numbers.
In his conjecture, Goldbach was considering 1 as a prime number. By
convention we no longer consider 1 as a prime number. And Euler later
modified the conjecture as follows:
Every even number greater than or equal to 4 can be expressed as
the sum of two prime numbers.
For example:
There is no formal proof of this conjecture. However, we can verify Goldbach's conjecture in certain ranges. For this programming assignment you are asked to verify Goldbach's conjecture in the range 4 through 100 (inclusive). Your output will print out all the even numbers in the range 4 to 100 in the form n = a + b, where a and b are prime numbers. Each even number should be on a separate line. Each pair of prime numbers should be unique. If there is more than one pair of prime numbers that add up to that even number, the first prime of each pair should be in ascending order. The sample output should look like this:
4 = 2 + 2 6 = 3 + 3 .... 42 = 5 + 37 = 11 + 31 = 13 + 29 = 19 + 23 .... 100 = ....
Your program should have a good, clean logical structure. You must make use of methods. We will be looking at good documentation, descriptive variable names, and adherence to the coding convention mentioned below. Your file Goldbach.java will have the following header:
/* File: Goldbach.java Description: Student Name: Student UT EID: Course Name: CS 303E Unique Number: Date Created: Date Last Modified: */
You will follow the standard Java Coding Conventions. You can either view the HTML page or download the PDF or Postscript and print it out. There is a modification that I would like to make to the standard coding conventions. Please align the opening and closing braces vertically so that you can easily make out the blocks of code. For example:
if ( x > 5 ) { a = b + c; } vs. if ( x > 5 ) { a = b + c; }
Use the turnin program to submit your .java file. The TAs should receive your work by 5 PM on Saturday, 18 July 2009. There will be substantial penalties if you do not adhere to the guidelines.