|
Groovy example source code file (sieve.java)
The Groovy sieve.java source code// $Id: sieve.java,v 1.1 2004-05-23 07:14:28 bfulgham Exp $ // http://www.bagley.org/~doug/shootout/ public class sieve { public static void main(String args[]) { int NUM = Integer.parseInt(args[0]); 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"); } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy sieve.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.