ref: 59d16c3900ebfdf0725ebab61e77499dfb7f86de
parent: 54a91861df5782fdc62ac72f8c8f3ce192f6396f
author: cinap_lenrek <[email protected]>
date: Sun Aug 23 19:49:31 EDT 2015
libsec: fix probably_prime() endless loop for n == 3
--- a/sys/src/libsec/port/probably_prime.c
+++ b/sys/src/libsec/port/probably_prime.c
@@ -21,10 +21,10 @@
nrep = 18;
k = mptoi(n);
- if(k == 2) /* 2 is prime */
- return 1;
if(k < 2) /* 1 is not prime */
return 0;
+ if(k == 2 || k == 3) /* 2, 3 is prime */
+ return 1;
if((n->p[0] & 1) == 0) /* even is not prime */
return 0;