A prime number is a number that is only evenly divisible by itself and 1. For ex
ID: 3530804 • Letter: A
Question
A prime number is a number that is only evenly divisible by itself and 1. For example, the number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6. Design a Boolean function named isPrime, which takes an integer as an argument and returns True if the argument is a prime number, or False otherwise. Use the function in a program that prompts the user to enter a number and then displays a message indicating whether the number is prime.Explanation / Answer
Pseudo code Function main //No arguments passed to main function Pass In: nothing //Declare variables Declare Integer number Declare Boolean result //Get the number Display “Enter an integer number” Input number //value returned by call to isPrime (number) function assigned to result result = Call: isPrime Pass In number If result is equal to True Then Display “number is prime” Else Display “number is non prime” End if //nothing (value zero) is returned by main to operating system Pass Out: value zero to the operating system End function Function isPrime //number is argument in this function Pass In: integer number //Declare variables Declare Integer count Declare Boolean prime count = two prime = True //while loop While countRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.