2 * The UCW Library -- Prime numbers
4 * (c) 2008 Michal Vaner <vorner@ucw.cz>
6 * Code taken from ucw/lib.h by:
8 * (c) 1997--2008 Martin Mares <mj@ucw.cz>
9 * (c) 2005 Tomas Valla <tom@ucw.cz>
10 * (c) 2006 Robert Spalek <robert@ucw.cz>
11 * (c) 2007 Pavel Charvat <pchar@ucw.cz>
13 * This software may be freely distributed and used according to the terms
14 * of the GNU Lesser General Public License.
22 #ifdef CONFIG_UCW_CLEAN_ABI
23 #define isprime ucw_isprime
24 #define next_table_prime ucw_next_table_prime
25 #define nextprime ucw_nextprime
26 #define prev_table_prime ucw_prev_table_prime
32 * Return a non-zero value iff @x is a prime number.
33 * The time complexity is `O(sqrt(x))`.
38 * Return some prime greater than @x. The function does not checks overflows, but it should
39 * be safe at least for @x lower than `1U << 31`.
40 * If the Cramer's conjecture is true, it should have complexity `O(sqrt(x) * log(x)^2)`.
47 * Quickly lookup a precomputed table to return a prime number greater than @x.
48 * Returns zero if there is no such prime (we guarantee the existance of at
49 * least one prime greater than `1U << 31` in the table).
51 uns next_table_prime(uns x);
54 * Quickly lookup a precomputed table to return a prime number smaller than @x.
55 * Returns zero if @x is smaller than `7`.
57 uns prev_table_prime(uns x);
59 #endif // _UCW_PRIME_H