You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
#include <stdio.h>
|
|
#include <math.h>
|
|
int main() {
|
|
int n,i,q;
|
|
int c = 0;
|
|
scanf("%d", &n);
|
|
q = sqrt(n);
|
|
for (i = 2; i <= q; i++ )
|
|
{
|
|
if(n % i == 0)
|
|
c++;
|
|
}
|
|
if (c ==0)
|
|
{
|
|
printf("%d是素数\n", n);
|
|
}
|
|
else {
|
|
printf("%d不是素数\n", n);
|
|
}
|
|
|
|
return 0;
|
|
} |