Factorial program in PHP using recursive function

160

Factorial program in PHP using recursive function -

<?php
function factorial($number) {

    if ($number < 2) {
        return 1;
    } else {
        return ($number * factorial($number-1));
    }
}

echo factorial(4);
?>

Comments

Submit
0 Comments