Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/ / TODO: include proper headers here #include #include / / what header is needed for square root function ? ? / / #include /

// TODO: include proper headers here
#include
#include
// what header is needed for square root function ??
// #include
// TODO: complete prime tester function
// to generate desired output.
bool isPrime( int number){
// TODO: complete the condition here
// guard negative numbers, 0 and 1, as they are not considered as prime numbers.
if (/*CONDITION*/){
return false;
}
// TODO: complete the for loop to test all possible factors
// possible factors starts from 2(inclusive) and goes all the way to sqrt(n)+1(inclusive)
for (/* LOOP */){
if (/* if evenly divisible by factor, then not a prime number */)
return false;
}
// no factor found, return true
return true;
}
// question 2:
// TA may give general guidelines but will not help on code level.
// develop a function to return the 10001st prime number.
// correct answer: 104743
int the10001PrimeNumber(){
}
// TODO: please finish the main function.
int main(){
// question 1's main() function requirement:
// generate following output by using isPrime() function:
/*
1 is NOT a prime number.
2 is a prime number.
3 is a prime number.
4 is NOT a prime number.
5 is a prime number.
6 is NOT a prime number.
7 is a prime number.
8 is NOT a prime number.
9 is NOT a prime number.
10 is NOT a prime number.
11 is a prime number.
12 is NOT a prime number.
13 is a prime number.
14 is NOT a prime number.
15 is NOT a prime number.
16 is NOT a prime number.
17 is a prime number.
18 is NOT a prime number.
19 is a prime number.
*/
// question 2's code.
// Please complete the function the10001PrimeNumber() first,
// then uncomment following code to generate desired output
// std::cout << "The 10001st prime number: "<< the10001PrimeNumber()<< std::endl;
}

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

Progress Monitoring Data Tracking Organizer

Authors: Teacher'S Aid Publications

1st Edition

B0B7QCNRJ1

More Books

Students also viewed these Databases questions

Question

. What does win mean in that phrase?

Answered: 1 week ago

Question

(c) What is the complete defining relationship? Pg45

Answered: 1 week ago

Question

107 MA ammeter 56 resistor ? V voltmeter

Answered: 1 week ago

Question

Generally If Drug A is an inducer of Drug B , Drug B levels will

Answered: 1 week ago

Question

suggest a range of work sample exercises and design them

Answered: 1 week ago