Goldbach's Conjecture (Due 22 October 2013)

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 a user defined range and determine what is the maximum number of pairs of prime numbers for a given even number in that range. For example, if the user specifies a range from 4 to 12, then your output will print out all the even numbers in the range 4 to 12 (both inclusive) in the form n = a + b, where a and b are prime numbers and a <= b. Each even number should be on a separate line followed by all possible unique pairs of prime numbers. Your sample output should look like this:

Enter lower limit: 4
Enter upper limit: 12

4 = 2 + 2
6 = 3 + 3
8 = 3 + 5
10 = 3 + 7 = 5 + 5
12 = 5 + 7

The maximum number of pairs = 2

In your program you should check if the lower limit is an even number greater than or equal to 4 and the upper limit is an even number, and the lower limit is less than or equal to the upper limit. You need to do just one test after both the lower limit and the upper limit have been entered. Prompt the user repeatedly to enter the lower limit and upper limit until he gets them right. There is no need of writing an error message.

Enter lower limit: 2
Enter upper limit: 7

Enter lower limit: 10
Enter upper limit: 4

Enter lower limit: 4
Enter upper limit: 10

Your program should have a good, clean logical structure. You must make use of function is_prime() that we developed. We will be looking at good documentation, descriptive variable names, and adherence to the coding convention discussed in class. Your file Goldbach.py will have the following header:


#  File: Goldbach.py

#  Description:

#  Student Name:

#  Student UT EID:

#  Course Name: CS 303E

#  Unique Number: 

#  Date Created:

#  Date Last Modified:

Use the turnin program to submit your Goldbach.py file. The proctors should receive your work by 11 PM on Tuesday, 22 October 2013. There will be substantial penalties if you do not adhere to the guidelines. The TA in charge of this assignment is Lee Thompson (parnell@cs.utexas.edu).

References