#include "stdio.h"
#include "stdlib.h"
#define ISNOTPRIMER(num) printf("The Number %d is not a primer\r\n",num)
#define ISPRIMER(num) printf("The Number %d is a primer\r\n",num)
/*
1.判断一个整数是否为素数
*/
void IsPrimer_Func()
{
int iNum;
int n = 2;
printf("Please put in the number firstly: ");
scanf("%d",&iNum);
putchar(10);
if(iNum<=1)
{
ISNOTPRIMER(iNum);
}
else
{
if (iNum == 2)
{
ISPRIMER(iNum);
}
else
{
for (n=2;n<iNum/2+1;n++)
{
if (iNum%n == 0)
{
break;
}
else
{
}
}
if (n == iNum/2+1)
{
ISPRIMER(iNum);
}
else
{
ISNOTPRIMER(iNum);
}
}
}
return;
}
void main()
{
IsPrimer_Func();
return;
}