diff --git a/函数判断素数.c b/函数判断素数.c new file mode 100644 index 0000000..e50fe97 --- /dev/null +++ b/函数判断素数.c @@ -0,0 +1,39 @@ +#include +#include +int judge(int m) +{ + int i,count=0; + if(m<2) + { + return 0; + } + for(i=2;i<=sqrt(m);i++) + { + if(m%i==0) + { + count++; + } + } + if(count==0) + { + return 1; + } + else + { + return 0; + } +} +int main() +{ + int n; + scanf("%d",&n); + if(judge(n)==1) + { + printf("Yes"); + } + else + { + printf("No"); + } + return 0; +}