X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=inline;f=ucw%2Fprime.c;h=a1ac86d44c2d2c9d2b73373bed1244c3b94687c1;hb=c8ffd6e3b4fc8fd6437c04282c357b2dc290bbbd;hp=12655492f5c626f1dffc020de8f463b47080a125;hpb=689b60e4c61d300b576fdb7007de51189d2f0f7e;p=libucw.git diff --git a/ucw/prime.c b/ucw/prime.c index 12655492..a1ac86d4 100644 --- a/ucw/prime.c +++ b/ucw/prime.c @@ -7,13 +7,13 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" -#include "ucw/prime.h" +#include +#include static int /* Sequential search */ -__isprime(uns x) /* We know x != 2 && x != 3 */ +__isprime(uint x) /* We know x != 2 && x != 3 */ { - uns test = 5; + uint test = 5; if (x == 5) return 1; @@ -33,7 +33,7 @@ __isprime(uns x) /* We know x != 2 && x != 3 */ } int -isprime(uns x) +isprime(uint x) { if (x < 5) return (x == 2 || x == 3); @@ -47,8 +47,8 @@ isprime(uns x) } } -uns -nextprime(uns x) /* Returns some prime greater than x */ +uint +nextprime(uint x) /* Returns some prime greater than x */ { x += 5 - (x % 6); /* x is 6k-1 */ for(;;) @@ -70,7 +70,7 @@ nextprime(uns x) /* Returns some prime greater than x */ int main(int argc, char **argv) { - uns k = atol(argv[1]); + uint k = atol(argv[1]); printf("%d is%s prime\n", k, isprime(k) ? "" : "n't"); printf("Next prime is %d\n", nextprime(k)); return 0;