Created
March 26, 2012 04:33
-
-
Save ccw/2202947 to your computer and use it in GitHub Desktop.
[Project Euler in Groovy] - P7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def primes = [2, 3, 5, 7, 11, 13, 17] | |
def MAX = 10001 | |
def i = primes.get(primes.size() - 1) + 1 | |
while (primes.size() < MAX) { | |
if(!primes.any { i % it == 0 }) { | |
primes << i | |
} | |
i++ | |
} | |
println "found primes size => ${primes.size()}" | |
println "the prime => ${primes.get(MAX > primes.size() ? primes.size() - 1 : MAX - 1)}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment