factorial program in php using recursive function

96

<?php
function factorial($number) {

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

echo factorial(4);
?>

Comments

Submit
0 Comments