Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions