Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

App Inventor

Authors: David Wolber, Hal Abelson

1st Edition

1449397484, 9781449397487

More Books

Students also viewed these Programming questions

Question

How do you want me to help you?

Answered: 1 week ago