Mercurial > projects > ldc
annotate test/sieve.d @ 11:d3ee9efe20e2 trunk
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
* Now 50/51 tests compile.
* Added a simple runalltests.d scripts that should be run with 'gdmd -run runalltests.d' - LLVMDC will not compile it yet.
author | lindquist |
---|---|
date | Tue, 02 Oct 2007 05:10:18 +0200 |
parents | c53b6e3fe49a |
children | d9d5d59873d8 |
rev | line source |
---|---|
1 | 1 /* Eratosthenes Sieve prime number calculation. */ |
2 | |
3 bool flags[8191]; | |
4 | |
5 int main() | |
6 { int i, prime, k, count, iter; | |
7 | |
8 printf("10 iterations\n"); | |
9 for (iter = 1; | |
10 iter <= 10; | |
11 iter++) | |
12 { | |
13 count = 0; | |
14 flags[] = true; | |
15 for (i = 0; i < flags.length; i++) | |
16 { if (flags[i]) | |
17 { | |
18 prime = i + i + 3; | |
19 k = i + prime; | |
20 while (k < flags.length) | |
21 { | |
22 flags[k] = false; | |
23 k += prime; | |
24 } | |
25 count += 1; | |
26 } | |
27 } | |
28 } | |
29 printf("%d primes\n", count); | |
30 return 0; | |
31 } |