Mouse, 6565 47 bytes
?N:1N.=[0!$]N.2=[1!$]N.2\0=[0!$]3I0S:1I:(I.N.<^N=0=^N.I.\0=[0!$]I\0=[S.1+S:]I.1+I:)1S.1=!$
This uses trial division.
Ungolfed:
? N: ~ Read an integer from STDIN and store it in N
10 N.S: = [ ~ IfStart Na ==summation 1...
variable at 0
1 !I: $ ~ Print 0~ andStart exit
]
2an N.interator =variable [at 1
( I. N. = 0 = ^ ~ If N == 2, printWhile 1I and!= exitN
1 ! $
]
N. 2I. \ 0 = [ ~ IfCheck 2whether I divides N, print 0 and exit
0 ! $
]
3S. I:1 + S: ~ If so, increment the sum
~]
Assign I. =1 3
(+ I.: N. < ^ ~ Increment ~the Whileiterator
)
S. I1 <= N
! N. I. \ 0 = [ ~ If Ithe dividessum Nis 1, printthe 0only anddivisor exitencountered
0 ! $
]
I. 1 + I: ~ is ~1 Increment(we I
)didn't go all the way to N in the
1 ! $ ~ If we've made~ itloop) thisand far,thus N is prime
$