sewardj | 0e4096b | 2005-09-28 11:25:10 +0000 | [diff] [blame] | 1 | |
| 2 | #include <stdio.h> |
njn | dd8cff8 | 2005-09-28 14:49:40 +0000 | [diff] [blame] | 3 | #include <math.h> |
sewardj | 0e4096b | 2005-09-28 11:25:10 +0000 | [diff] [blame] | 4 | |
| 5 | int isprime ( int n ) |
| 6 | { |
| 7 | int m; |
njn | dd8cff8 | 2005-09-28 14:49:40 +0000 | [diff] [blame] | 8 | int sqrt_n = sqrt(n); |
| 9 | for (m = 2; m <= sqrt_n+1; m++) // +1 in case of obscure rounding error |
sewardj | 0e4096b | 2005-09-28 11:25:10 +0000 | [diff] [blame] | 10 | if ((n % m) == 0) return 0; |
| 11 | return 1; |
| 12 | } |
| 13 | |
| 14 | int main ( int argc, char** argv ) |
| 15 | { |
| 16 | int i; |
| 17 | for (i = 79000; i < 81000; i++) |
| 18 | if (isprime(i)) { printf ( "%d ", i ); fflush(stdout); } |
| 19 | return 0; |
| 20 | } |