Skip to content

Instantly share code, notes, and snippets.

@ccw
Created March 26, 2012 04:33
Show Gist options
  • Save ccw/2202947 to your computer and use it in GitHub Desktop.
Save ccw/2202947 to your computer and use it in GitHub Desktop.
[Project Euler in Groovy] - P7
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