Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please add classes ( . h and . cpp ) when creating code for 1 0 0 0 1 th prime number / / TODO:

Please add classes (.h and .cpp) when creating code for 10001th prime number
// 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:
// 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

Excel 2024 In 7 Days

Authors: Alan Dinkins

1st Edition

B0CJ3X98XK, 979-8861224000

Students also viewed these Databases questions