Programming Concepts — Recursion
Recursion is a technique where a function calls itself to solve a smaller instance of the problem until it reaches a base case.
function factorial(n) {
if (n === 1) return 1;
return n * factorial(n - 1);
}
console.log(factorial(5)); // Output: 120