Bool isprime (int n) {int I, limit; If (n <= 1) return false; If (n = 2) return true; // 2 is an IF (N % 2 = 0) return false; // This step can simplify the subsequent steps. See step I + = 2, the step size can be increased by limit = SQRT (n) + 1; // determine whether a certain number is a combination, for example, 49, as long as 3 ~ 7. So SQRT is used. // But why + 1? Because SQRT returns a floating point number. Write the compiler again. If you want to return the 49-open-end number, but return the 6.99999 value, the integer variable limit is truncated to 6, and the error is returned. It is better to calculate an approximate number. For (I = 3; I <= limit; I + = 2) // The step size is 2, because the divisible by 2 has been excluded {If (N % I = 0) return false ;}// when determining whether 3 is a prime number, limit = 2, the prime number is exactly the prime number, and the prime number following it will surely be obtained.