def startTime = System.currentTimeMillis() def fact = {it -> sleep(100); it ? it * call(it - 1g) : 1g} fact = fact.memoize() println fact(70) println fact(71) println ((System.currentTimeMillis() - startTime) / 1000.0)