• + 0 comments

    My solution with JavaScript:

    // Base case at 2 to avoid redundancy: multiplying by 1 does not change the result.
    function factorial(n) {
        if(n > 2) {
            return n * factorial(n-1);
        } else {
            return 2;
        }
    }