repo.or.cz
/
dragonfly.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
test
[dragonfly.git]
/
contrib
/
top
/
prime.c
blob
b0d65424b5e0baa03bf9516bcd974ffcd41aafd9
1
/*
2
* Prime number generator. It prints on stdout the next prime number
3
* higher than the number specified as argv[1].
4
*/
5
6
#include <stdio.h>
7
#include <math.h>
8
9
main
(
argc
,
argv
)
10
11
int
argc
;
12
char
*
argv
[];
13
14
{
15
double
i
,
j
;
16
int
f
;
17
18
if
(
argc
<
2
)
19
{
20
exit
(
1
);
21
}
22
23
i
=
atoi
(
argv
[
1
]);
24
while
(
i
++)
25
{
26
f
=
1
;
27
for
(
j
=
2
;
j
<
i
;
j
++)
28
{
29
if
((
i
/
j
)==
floor
(
i
/
j
))
30
{
31
f
=
0
;
32
break
;
33
}
34
}
35
if
(
f
)
36
{
37
printf
(
"%.0f
\n
"
,
i
);
38
exit
(
0
);
39
}
40
}
41
}