-->
当前位置:首页 > 题库

PROGRAMMING:The search for prime numbers

Luz5年前 (2021-05-10)题库405
Prime numbers are positive integers that cannot be divisible by integers other than 1 and itself. According to this definition, * * - negative numbers, 0 and 1 are not prime numbers * *, while 17 is prime because it cannot be divisible by any integer between 2 and 16 except 1 and 17.
Use the integer from * * 2 to sqrt (m) * * (the square root of M) to test the quotient
*If M can be divided by an integer in the above range (the remainder is 0), then M is not a prime;
*If each integer between the above ranges cannot divide m, then M is a prime.
According to the above algorithm to write the function isprime (), input an integer m from the keyboard to determine whether M is a prime.
###Function interface definition
```
int IsPrime(int m);
```
Where ` m 'is the number entered by the user.
If'm 'is a prime, the function returns' 1'; Otherwise, the function returns ` 0`
###Input format:
The user enters any positive integer M.
###Output format:
See output example:
If M is a prime number, output it in the format of '% d is a prime number', '
Otherwise, output the number according to the format of '% d is not a prime number'; the number is not a prime number
###Input example:
```in
seven
```
###Output example:
```out
7 is a prime number
```
###Input example:
```in
one
```
###Output example:
```out
1 is not a prime number
```






answer:If there is no answer, please comment