|
Groovy example source code file (nsieve.groovy)
The Groovy nsieve.groovy source code/* The Computer Language Benchmarks Game http://shootout.alioth.debian.org/ contributed by Pilho Kim */ def countSieve(m, primes) { def i, k def count = 0 i = 2 while (i <= m) { primes[i] = true i++ } i = 2 while (i <= m) { if (primes[i]) { k = i + i while (k <= m) { primes[k] = false k += i } count++ } i++ } return count } def padNumber(number, fieldLen) { def bareNumber = "" + number def numSpaces = fieldLen - bareNumber.length() def sb = new StringBuffer(" "*numSpaces) sb.append(bareNumber) return sb.toString() } def n = 2 if (args.length > 0) n = args[0].toInteger() if (n < 2) n = 2 def m = (1< |
... 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.