int IsPrime(int n) { int i; if (n < 2) return 1; for (i = 2; i * i <= n; i++) if (n % i == 0) return 1; return 0; } int main() { int n; scanf("%d", &n); if (IsPrime(n) == 0) printf("%d is prime!\n", n); else printf("%d is not prime!\n", n); return 0; }
2,
#include <stdio.h> #include <math.h> # define e 2.7182818284590452354