#include <stdio.h>
#include <math.h>
int
even (int n)
{
return (!(n%2));
}
int
prime2 (int n, int *divisor)
{
int i, is_prime;
*divisor = 0;
if (even (n))
{
if (n==2)
*divisor=0;
else
*divisor=2;
}
else
{
if (n==1)
*divisor=0;
else
for (i=3; i<=sqrt(n); i=i+2)
{
if (!(n%i))
*divisor=i;
}
}
is_prime = *divisor;
return (!is_prime);
}
int
main (void)
{
int x, div;
printf ("Enter a positive integer number: ");
scanf ("%d", &x);
if (prime2 (x, &div))
printf ("%d is a prime number.\n", x);
else
printf ("%d not prime number. Divisible by %d.\n", x, div);
return (0);
}