1
0
Fork 0

lib/prime.c: fixed a bug where 2 was not a prime in is_prime().

This commit is contained in:
Henrik Hautakoski 2010-06-18 16:32:03 +02:00
parent f22af0ffaf
commit 428e392868
2 changed files with 2 additions and 1 deletions

View file

@ -6,6 +6,8 @@ int is_prime(uint32_t p) {
uint32_t i, l; uint32_t i, l;
if (p == 2)
return 1;
if (p < 2 || (p & 1) == 0) if (p < 2 || (p & 1) == 0)
return 0; return 0;

View file

@ -1,6 +1,5 @@
#ifndef __PRIME_H #ifndef __PRIME_H
#define __PRIME_H #define __PRIME_H
#include <stdint.h> #include <stdint.h>