2007-12-06 Jb Evain <jbevain@novell.com>
[mono.git] / mono / tests / sieve.cs
blob95d343e5d9d8e4d7637a33420bc43664c0d720dc
1 /* -*- mode: c -*-
2 * $Id$
3 * http://www.bagley.org/~doug/shootout/
4 */
6 class Test {
7 static public int Main() {
8 //int NUM = ((argc == 2) ? atoi(argv[1]) : 1);
9 int NUM = 300;
10 byte[] flags = new byte[8192 + 1];
11 int i, k;
12 int count = 0;
14 while (NUM-- != 0) {
15 count = 0;
16 for (i=2; i <= 8192; i++) {
17 flags[i] = 1;
19 for (i=2; i <= 8192; i++) {
20 if (flags[i] != 0) {
21 // remove all multiples of prime: i
22 for (k=i+i; k <= 8192; k+=i) {
23 flags[k] = 0;
25 count++;
29 System.Console.WriteLine("Count: {0}\n", count);
30 return(0);