All pastes #979509 Raw Edit

Unnamed

public java v1 · immutable
·published 2008-04-10 12:32 UTC
rendered paste body
// $Id: sieve.java,v 1.8 2001/05/06 04:37:45 doug Exp $// http://www.bagley.org/~doug/shootout///** This copy courtesy of http://www.kano.net/javabench///**  Added Timer() codepublic class sieve {    public static void main(String args[]) {	int NUM = Integer.parseInt(args[0]);    long start = System.currentTimeMillis();  	boolean [] flags = new boolean[8192 + 1];	int count = 0;	while (NUM-- > 0) {	    count = 0;	    for (int i=2; i <= 8192; i++) {		flags[i] = true;	    }	    for (int i=2; i <= 8192; i++) {		if (flags[i]) {		    // remove all multiples of prime: i		    for (int k=i+i; k <= 8192; k+=i) {			flags[k] = false;		    }		    count++;		}	    }	}  	System.out.print("Count: " + count + "\n");    long end = System.currentTimeMillis();     System.out.println("Time: " + (end - start) + " ms");     }}