Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A prime number is a positive integer whose positive integer divisors are 1 and the number. E.g. 17 is a prime number -23 is a

A prime number is a positive integer whose positive integer divisors are 1 and the number.

E.g. 17 is a prime number

-23 is a not prime number

28 is not a prime number

-45 is not a prime number

The only even prime number is 2

Write a boolean function, isPrime that return true if its integer parameter is a prime and false if its integer parameter is not a prime number.

A simple prime number algorithm is

if n < 1 then return false

else if n = 2 then return true

else if n is an even number then return false

else

upper bound = square root(n) + 1

candidate = 3

while candidate <= upper bound and candidate does not divide n

add 2 to candidate

end while

if some condition is true

return false

else

return false

end if

end while

Write a one parameter boolean function that returns true if its parameter is a prime number and false if its parameter is not a prime number.

*Note: I need help to write out this problem in C++ while using Visual Studio 2017

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions