I had to do this for my intro class, I just used
if( (n%2) == 1)
it's a prime
else
it's not prime
bool p(int a){return n%2;}
Tiny version, some compiliers allow instant convesions from int to bool.
edit: this finds if it's odd or not
God dam it, I was linked this thread and forgot it was old.