Question: IN C++ Optimize the program by calculating the square root of n just once, rather than repeatedly. You'll need to declare another variable and set
IN C++ Optimize the program by calculating the square root of n just once, rather than repeatedly. You'll need to declare another variable and set it to the square root of n. The type should be DOUBLE. You can then use this variable in the "while" conditiion. The program is a program called prime1.cpp which will be shown below.

Lastly, how would I optimize this shown below?
while ( i
if ( n% i == 0 ) {
is_prime = false;
}
i++;
}
prime1.cpp #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
