Question: Write a python function that takes a number as a parameter and determines if its prime or not. A prime number is a natural number

Write a python function that takes a number as a parameter and determines if its prime or not. A prime number is a natural number greater than 1 and that has no positive divisors other than 1 and itself.

Allow the user to enter a number. Check to see that the number has been entered and is greater than zero Pass the number to a value returning function that determines if the number is prime and returns a Boolean variable true of false The main routine will display a message indicating prime or not based on the true/false.

If the number is 1 its not consider prime- If the number is 2 it is prime To check if any other entered number is prime. Create a loop from 2 to the entered number. If the entered number is evenly divisible by any number in the loop range, its not prime.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!