// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
def fib(n) {
    return n < 2 ? n : fib(n - 1) + fib(n - 2)
}

REP = 5
println("Groovy:")
for(i in 1..REP) {
    t0 = System.currentTimeMillis()
    ans = fib(45)
    t1 = System.currentTimeMillis()
    println("fib(45) = ${ans} took ${(t1 - t0) / 1000.0} seconds.")
}
