#include#include #include int prime(int num){ int k = 0; int i = 0; k = sqrt(num); for (i = 2; i <= k; i++) /*不满足循环条件时即均不可被整除,不是素数*/ { if (num%i == 0) { return 0; } } return -1;}int main(){ int num = 0; int ret = 0; printf("please input the number:\n"); scanf("%d", &num); ret = prime(num); if (ret == 0) //不是素数 { printf("%d is not prime", num); } else //是素数 { printf("%d is prime", num); } system("pause"); return 0;}