Find Factorial Recursive

Find Factorial Recursive

Finding wether if algorithm can works recorsevily

Example:
findFactorialRecurative(5)} 120


function findFactorialRecursive(number) {
  if ( number == 2){
    return 2;
  }
  return number * findFactorialRecursive(number-1);
}

findFactorialRecursive(5)

We create a function findFactorialRecurative with parameter of number

We check wheter number is equal to 2 and if it is we return 2.

We return the number * findFactorialRecurative(number-1)

So we have number 5 * 4 * 3* 2 * 1 = 120

comments powered by Disqus