Functions
Check Prime Using Function
Check whether a number is prime using a user-defined function.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Check whether a number is prime using a user-defined function.
#include <stdio.h>
int isPrime(int n) {
if (n < 2) return 0;
for (int i = 2; i * i <= n; i++)
if (n % i == 0) return 0;
return 1;
}
int main() {
int n;
scanf("%d", &n);
printf(isPrime(n) ? "Prime\n" : "Not Prime\n");
return 0;
}
17
Prime