Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Program for factorial of a number in php

<?php
// PHP program to find factorial
// of given number
 
// function to find factorial
// of given number
function factorial($n)
{
    if ($n == 0)
        return 1;
    return $n * factorial($n - 1);
}
 
    // Driver Code
    $num = 5;
    echo "Factorial of ", $num, " is ", factorial($num);
 
// This code is contributed by m_kit
?>
 
PREVIOUS NEXT
Tagged: #Program #factorial #number #php
ADD COMMENT
Topic
Name
3+6 =