Racket Assignment
Due: March 11
Overview
The Goldbach conjecture states that every even number greater than two is the sum of two prime numbers. For example:
6 = 3 + 3 12 = 5 + 7 38 = 7 + 31 10000 = 59 + 9941
The conjecture has never been proven, but has shown been shown to hold for every even number greater than two up to at least 4 quintillion.
You will write a program that reads in a number from the user, verifies that it is even and greater than 2, and prints out two prime numbers that sum to the value the user entered.
Example run:
Enter an even value: 91 That number is not even. Enter an even value: 0 That number is not greater than two. Enter an even value: 90 The two primes that add to 90 are 7 and 83.
Your program should continue asking for a value until it is given an even number greater than 2.
Using packages from the Racket "Planet" repository is not allowed, but anything included with the Racket standard library is.
Tips
- Start by writing a function that tests whether a number is prime.
- Then write a function that uses this (and filter) to create a list of prime numbers from 2 to the value they entered.
- Once you have a list of primes, recurse over it testing each number.
- There may be multiple pairs of primes that add to the value, any is acceptable.
- Other functions that may come in handy:
- modulo
- member
- even?
- first
- rest
Submitting
Submit your Racket file to Canvas for this assignment.