各位新年快乐!一个素数程序,显示错误,求解答!
#include "math.h"#include "stdio.h"
void main()
{
int n,ret;
printf("Input n:");
scanf("%d",&n);
ret=IsPrimeNumber(n);
if(ret!=0)
{
printf("%d is a prime number\n",n);
}
else
{
printf("%d is not a prime number\n",n);
}
}
int IsPrimeNumber(int number)
{
int i;
if(number<=1)
return 0;
for(i=2;i<=sqrt(number);i++)
{
if((number%i)==0)
return 0;
}
return 1;
}