X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Feratosthenes%2Feratosthenes.h;fp=ccan%2Feratosthenes%2Feratosthenes.h;h=0ec4692d81bd232dffc28444eb9ce3899699f1fe;hb=c5e84ef2b5687fc35cdffa4768da13674afb8977;hp=0000000000000000000000000000000000000000;hpb=f591ef48f887f6c1608cdd89d78eebacd27e8552;p=ccan diff --git a/ccan/eratosthenes/eratosthenes.h b/ccan/eratosthenes/eratosthenes.h new file mode 100644 index 00000000..0ec4692d --- /dev/null +++ b/ccan/eratosthenes/eratosthenes.h @@ -0,0 +1,27 @@ +/* Licensed under LGPLv2+ - see LICENSE file for details */ +#ifndef CCAN_ERATOSTHENES_H_ +#define CCAN_ERATOSTHENES_H_ + +#include "config.h" + +#include + +#include + +struct eratosthenes { + unsigned long limit; + bitmap *b; +}; + +void eratosthenes_init(struct eratosthenes *s); + +void eratosthenes_reset(struct eratosthenes *s); + +void eratosthenes_sieve(struct eratosthenes *s, unsigned long limit); + +bool eratosthenes_isprime(const struct eratosthenes *s, unsigned long n); + +unsigned long eratosthenes_nextprime(const struct eratosthenes *s, + unsigned long n); + +#endif /* CCAN_ERATOSTHENES_H_ */