repo.or.cz
/
C-Programming-Examples.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Added stack address randomization example.
[C-Programming-Examples.git]
/
primes.c
blob
f77190f963f7f56a519dd0d9c1a18c89ecd6833c
1
#include <stdio.h>
2
#include <stdbool.h>
3
4
int
isPrime
(
int
);
5
6
int
main
(
void
)
7
{
8
int
num
=
2
;
9
int
max
;
10
11
printf
(
"Input Maximum Prime: "
);
12
scanf
(
"%d"
, &
max
);
13
14
while
(
num
<
max
)
15
{
16
if
(
isPrime
(
num
)) {
printf
(
"%d
\n
"
,
num
); }
17
num
++;
18
}
19
return
0
;
20
}
21
22
int
isPrime
(
int
n
)
23
{
24
int
dev
;
25
26
for
(
dev
=
2
;
dev
<=
n
/
2
;
dev
++)
27
{
28
if
((
n
%
dev
) ==
0
) {
return false
; }
29
}
30
return true
;
31
}