#include <stdio.h>
int is_sushu(int);
int main(int argc, int *argv[])
{
int a,b;
printf("please input a number:");
scanf("%d",&a);
if (is_sushu(a))
{
printf("%d is sushu.\n",a);
}
else
{
printf("%d not sushu.\n",a);
}
system("pause");
return 0;
}
int is_sushu(int n)
{
int result = 0;
int i;
if (n <= 1)
{
return result;
}
if(2 == n)
{
result = 1;
return result;
}
for (i = 2; i < n ;i++)
{
if (0 == n % i)
{
result = 0;
break;
}
else if (i + 1 == n)
{
result = 1;
}
else
{
continue;
}
}
return result;
}
|