Question
Python: I need help so bad!!!! Thank you Prime Number Checker: You will write a program that finds and prints all the factors of a
Python: I need help so bad!!!!
Thank you
Prime Number Checker:
You will write a program that finds and prints all the factors of a given number and checks whether it is a prime number.
Specifically,
Write a function calledgetFactorsthat takes a number as a parameter, calculates all its factors and returns them in a list. Hint: a number F is a factor of number N if N is divisible by F. e.g. 3 is a factor of 6 because 6 is divisible by 3 (6 % 3 == 0) Use a for-loop to go through all the numbers less than given number N. Use the % operator to check divisibility.
Your main program
Asks user for a positive number strictly between 1 and 5000.(NO NEED TO VALIDATE THE INPUT)
Calls thegetFactorsfunction and gets the list of factors.
Prints all the factors, and the total count of factors.(See the sample run below)
Next checks if the given number is prime. A prime number is only divisible by two factors (1 and itself). For example, 7 is a prime number because it is only divisible by 1 and 7, but 12 is not a prime number because it is divisible by 1,2,3, 4, 6 and 12.
Next asks user if the program should continue.
If user enters y, repeats steps 1-5
Else exits.
See the sample run
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started