Mouse, 65 bytes
?N:1N.=[0!$]N.2=[1!$]N.2\0=[0!$]3I:(I.N.<^N.I.\0=[0!$]I.1+I:)1!$ This uses trial division.
Ungolfed:
? N: ~ Read an integer from STDIN and store it in N 1 N. = [ ~ If N == 1... 0 ! $ ~ Print 0 and exit ] 2 N. = [ ~ If N == 2, print 1 and exit 1 ! $ ] N. 2 \ 0 = [ ~ If 2 divides N, print 0 and exit 0 ! $ ] 3 I: ~ Assign I = 3 ( I. N. < ^ ~ While I < N N. I. \ 0 = [ ~ If I divides N, print 0 and exit 0 ! $ ] I. 1 + I: ~ Increment I ) 1 ! $ ~ If we've made it this far, N is prime