Current Path : /usr/src/contrib/top/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //usr/src/contrib/top/prime.c |
/* * Prime number generator. It prints on stdout the next prime number * higher than the number specified as argv[1]. */ #include <stdio.h> #include <math.h> main(argc, argv) int argc; char *argv[]; { double i, j; int f; if (argc < 2) { exit(1); } i = atoi(argv[1]); while (i++) { f=1; for (j=2; j<i; j++) { if ((i/j)==floor(i/j)) { f=0; break; } } if (f) { printf("%.0f\n", i); exit(0); } } }