From bbbaba2f77e2a34b7fdb84cfbf82ed242d2df86b Mon Sep 17 00:00:00 2001 From: pbqa92cj6 <2956318246@qq.com> Date: Sun, 13 Feb 2022 10:23:52 +0800 Subject: [PATCH] ADD file via upload --- 函数判断素数.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 函数判断素数.c 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; +}