COP2002 Project 4-1: Prime Number Checker solution

$24.99

Category:

Description

5/5 - (3 votes)

Create a program that checks whether a number is a prime number. The display
should include whether or not the number is prime and a list of the number’s factors. For
numbers that are not prime, also include the number of factors for that number.
Console
Prime Number Checker
Please enter an integer between 1 and 5,000: 7
The factors of your number are:
1
7
7 is a prime number.
Try again? (y/n): y
Please enter an integer between 1 and 5,000: 12
The factors of your number are:
1
2
3
4
6
12
12 is NOT a prime number.
It has 6 factors.
Try again? (y/n): n
Specifications
 A prime number is divisible by two factors (1 and itself). For example, 7 is a prime number because it
is only divisible by 1 and 7.
 If the number is prime, the program should display its factors (1 and the number itself).
 If the number is not a prime number, the program should display the factors and its number of factors.
 Store the code that gets a valid integer for this program in its own function.
 Store the code that calculates the number of factors and displays the factors for a number in a
function.
 Store the rest of the code that gets input and displays output in the main function.
 Save the file with the filename primes_XXX.py where XXX is either your initials or your last name.