mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-16 10:20:30 +00:00
aee34003d7
the src/contrib/top part right now). This tools is simply too system- dependant to maintain it in the ports collection.
41 lines
458 B
C
41 lines
458 B
C
/*
|
|
* Prime number generator. It prints on stdout the next prime number
|
|
* higher than the number specified as argv[1].
|
|
*/
|
|
|
|
#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);
|
|
}
|
|
}
|
|
}
|