0
how to use recursion in php
1 Answer
+ 4
function factorial($n)
{
if ($n < 0)
return -1;
if ($n == 0)
return 1;
return ($n * factorial ($n -1));
}
You can do recursion in PHP like this it's a simple function to find factorial of a number.