Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this activity, you are going to be thinking about how to test the isPrime function which takes a number and tests if it is

In this activity, you are going to be thinking about how to test the isPrime function which takes a number and tests if it is prime.
For each question, we will describe a mistake that the programmer might have made in writing isPrime. We will imagine that there
is a check function that takes the number with which to test isPrime, and the expected answer (True or False). The check function
might look something like this:
For each question, your answer should be a single call to check that identifies the problem described in the question prompt. For
example, if the question prompt suggests that isPrime (3) does not work correctly, you could answer
check (3, True)
to identify the mistake.
Suppose the programmer writing isPrime mistakenly thought that all prime numbers were odd, so they first
checked if the number passed in is even, and if so, returned False right away.
That looks like a great testcase
Suppose the programmer could not think of a general algorithm so instead they just checked several specific case
with the first several prime numbers:
image text in transcribed

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

Professional SQL Server 2000 Database Design

Authors: Louis Davidson

1st Edition

1861004761, 978-1861004765

More Books

Students also viewed these Databases questions