2 * UCW Library -- Prime Number Tests
4 * (c) 1997 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
12 static int /* Sequential search */
13 __isprime(uns x) /* We know x != 2 && x != 3 */
38 return (x == 2 || x == 3);
50 nextprime(uns x) /* Returns some prime greater than x */
52 x += 5 - (x % 6); /* x is 6k-1 */
70 main(int argc, char **argv)
72 uns k = atol(argv[1]);
73 printf("%d is%s prime\n", k, isprime(k) ? "" : "n't");
74 printf("Next prime is %d\n", nextprime(k));