Groovy web console

subscribe to the feed Subscribe
to this
site
Fatorial (via #groovywebconsole)
tweet this snippet Tweet
this
script

Fatorial

Published 7 months ago by Ronaldinho Gaucho with tags fatorial
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def fatorial(int x) {
int res = 1

for(int i = 1; i <= x; i++) {
    res = res * i
    println res
}

return res
}

int num = fatorial(10)

println "Resultado = "+ num