Python Loops
Part 1: Determine if a number is Prime
A positive whole number, n > 2, is prime if no number between 2 and the square root of (inclusive) evenly divides n. Write a program that accepts a value of n as input, and determines if the value is prime. If n is no prime, your program should quit as soon as it finds a value that evenly divides n.
Part 2: Lists of Prime Numbers
Modify your program to find every prime number less than or equal to n. [Hint: add an outer loop]
Part 3: Goldbach Conjecture (BONUS 20 pts Extra Credit)
The Goldbach conjecture asserts that every even number is the sum of two prime numbers. Write a program that gets a number from the user, checks to make sure that it is even, then finds two prime numbers that add up to the number.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 1 | 2 | 3 | 4 | 5 |