def primes = [] def num = 2; while (primes.size() < 10001) { if (!primes.find {num % it == 0}) { primes << num } num++ } println primes.last()