X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fprime.c;h=a1ac86d44c2d2c9d2b73373bed1244c3b94687c1;hb=0eb6d8317cdbdb28663ff779d31684b3c7a47274;hp=1139aa263f4799a3f886bdedde1daeca019c3ee3;hpb=031256ad2e123eec58521f8e3eb9496c197641d2;p=libucw.git diff --git a/ucw/prime.c b/ucw/prime.c index 1139aa26..a1ac86d4 100644 --- a/ucw/prime.c +++ b/ucw/prime.c @@ -7,12 +7,13 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.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; @@ -32,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); @@ -46,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(;;) @@ -69,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;