You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
377 B
26 lines
377 B
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
|
|
bool is_prime(int n) {
|
|
int divisor;
|
|
|
|
if (n <= 1)
|
|
return false;
|
|
for (divisor = 2; divisor * divisor <= n; divisor++)
|
|
if (n % divisor == 0)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
int main(void) {
|
|
int n;
|
|
|
|
printf("Enter a number: ");
|
|
scanf("%d", &n);
|
|
if (is_prime(n))
|
|
printf("Prime\n");
|
|
else
|
|
printf("Not prime\n");
|
|
|
|
return 0;
|
|
}
|
|
|