Recursion Lab: Calculate Factorials

Medium
1
50.0% Acceptance

In this lab, you will create a recursive function called factorial to calculate the factorial of a given number n. A factorial is the product of all positive integers less than or equal to n (denoted as n!). The factorial function takes n as the input and starts multiplying the numbers from 1 to the given number n. For example, the factorial of 5 would be: 5! = 5 * 4 * 3 * 2 * 1 = 120.

Recursion is a programming technique where a function calls itself in order to solve a problem. In this lab, you will use recursion to implement the factorial function.

After writing the factorial function, you have to export it from your index.js file using ESM syntax.