Write a function that determines whether anumber is prime. Use this function in
ID: 3613071 • Letter: W
Question
Write a function that determines whether anumber is prime.
Use this function in a program that determinesand prints all the prime numbers between 2 and 10,000. How many ofthese numbers do you really have to test before being sure that youhave found all the primes?
Initially, you might think that n/2 is the upperlimit for which you must test to see whether a number is prime, butyou need only go as high as the square root of n. Why? Rewrite theprogram, and run it both ways. Estimate the performanceimprovement.
Explanation / Answer
please rate - thanks #include #include #include using namespace std; int main() {int i,max=10000,j,factors; time_t t1=time(NULL); for(j=2;jRelated 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.