I understand that \"a\" solution is:
function Factorial(number)
{
if(number == 0 || number == 1){
return 1
Recursion relies on what is called a base case:
if(number == 0 || number == 1){
return 1;
}
That if
statement is called your base case. The base case defines when the recursion should stop. Note how you are returning 1
not returning the result of a call to the function again such as Factorial(number -1)
If the conditions for your base case are not met (i.e. if number
is NOT 1 or 0) then you proceed to call the function again with number * Factorial(number - 1)