发布网友 发布时间:2024-08-19 07:36
共2个回答
热心网友 时间:2024-08-23 04:48
#include<stdio.h>
#include<math.h>
int prime(int x,int k)
{if(x%k)
if(k>2)return prime(x,k-1);
else return 1;
else return 0;
}
int main()
{int n,t;
scanf("%d",&n);
t=sqrt(n);
if(prime(n,t))printf("Yes\n");
else printf("No\n");
getch();
return 0;
}
热心网友 时间:2024-08-23 04:51
def is_prime(n):
def prime_helper(k):
if k == 0:
return 0
elif n % k == 0:
return 1 + prime_helper(k-1)
elif n % k != 0:
return 0 + prime_helper(k-1)
if prime_helper(n) != 2:
return False
else:
return True