仅供学习使用:
/*********************************************
* Name : prime.c
* Purpose : prime (素数判断)
* Author : zimo
* Date : 01/21/2010
* ******************************************/
#include<stdio.h>
int main()
{
int m , n ;
printf("Enter a number: ");
scanf("%d",&n);
for (m = 2 ;m < n ;m++)
if (n % m ==0)
break;
if (m < n)
printf("%d is divisble by %d /n", n , m);
else
printf("%d is prime. /n",n);
return 0;
}