Question: State a good candidate for loop invariant. No proof required. Function to check if a number is prime boolean isPrime ( int n ) Check
State a good candidate for loop invariant. No proof required. Function to check if a number is prime boolean isPrimeint n Check numbers from to the square root of n for int i ; Math.sqrtn; If is divisible by it's not prime if xi return false; If no divisor is found, is prime return true
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
