Added stack address randomization example.
[C-Programming-Examples.git] / primes.c
blobf77190f963f7f56a519dd0d9c1a18c89ecd6833c
1 #include <stdio.h>
2 #include <stdbool.h>
4 int isPrime(int);
6 int main(void)
8 int num = 2;
9 int max;
11 printf("Input Maximum Prime: ");
12 scanf("%d", &max);
14 while ( num < max )
16 if(isPrime(num)) { printf("%d\n", num); }
17 num++;
19 return 0;
22 int isPrime(int n)
24 int dev;
26 for(dev = 2; dev <= n/2; dev++)
28 if((n % dev) == 0) { return false; }
30 return true;