Recursive Functions : Function Recursion « Functions « PHP






Recursive Functions

 
function factorial($number) {
            if ($number =  = 0) return 1;
            return $number * factorial($number--1);
    }

    print factorial(6);
  
  








Related examples in the same category

1.Define recursive function to delete directories
2.Function Recursion Demo
3.A recursive function is a function that calls itself from within its own code.
4.Using a recursive function to sum an integer set
5.Recursive Function Example