v1
2/14/2023 by hkotsubo -00
Setup HTML - click to add setup HTML
disable setup JavaScript
Setup JavaScript
function recursiveFat(n) {
    if (n == 0) {
        return 1;
    }
    return n * recursiveFat(n - 1);
}

function iterativeFat(n) {
    var fat = 1;
    // não preciso multiplicar o 1 porque não muda nada, posso começar do 2 mesmo
    // se n for menor que 2, ele nem entra no for e o resultado será 1
    for (var i = 2; i <= n; i++) {
        fat *= i;
    }
    return fat;
}

var n = 100;
delete caserun single casemove downdrag and drop case


ready



iterativeFat(n);
delete caserun single casemove updrag and drop case


ready



recursiveFat(n);
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN