#include<stdio.h>
main()
{ int i,j; scanf("%d",&i); for(j=2;j<=i/2;j++) if(i%j==0) break; if(j==i/2+1) printf("the number is a sushu",i); else printf("no sushu"); }
这个可以吗,
bool IsPrime(unsigned short n)
{
if (n % 2 == 0)
{
return n == 2;
}
if (n % 3 == 0)
{
return n == 3;
}
if (n % 5 == 0)
{
return n == 5;
}
for (unsigned short i = 7; i * i <= n; i += 2)
{
if (n % i == 0)
{
return false;
}
}
return true;
}