Groovy web console

subscribe to the feed Subscribe
to this
site

Big Factorial

Published 4 weeks ago by Sayo with tags factorial recursion
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def factorial(num) {
    if (num < 0) throw new IllegalArgumentException("Input cannot be less than zero")
    if (num <= 1) return num
    return num * factorial(num - 1)
}

println(factorial(new BigInteger(500)))