If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
<?php
/*define a recursive function to calculate factorial of a number.
* @param int.
* return int.
*/
function find_fact($number)
{
if ($number == 0)
{
return 1;
}
/* Recursion */
$result = ( $number * find_fact( $number-1 ) );
return $result;
}
echo "The factorial of 5 is: " . find_fact( 5 ).'<br>';
echo "The factorial of 10 is: " . find_fact( 10 );
?>
The factorial of 5 is: 120 The factorial of 10 is: 3628800
Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)
Get connected with me. :) LinkedIn Twitter Instagram Facebook