#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> #include<stdlib.h> int prime(num) { int i; for (i = 2; i < num / 2; i++) { if (num%i == 0) return 0; else return 1; } } int main() { int num; int ret = 0; scanf("%d", &num); ret = prime(num); if (ret == 1) printf("%d是素數\n", num); else printf("%d不是素數\n", num); system("pause"); return 0; }