Q:

Write a function to calculate the factorial of a number (a non-negative integer)

0

Write a function to calculate the factorial of a number (a non-negative integer). The function accepts the number as an argument

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
function factorial_of_a_number($n)
{
  if($n ==0)
    {
	   return 1;
    }
  else 
    {	
	   return $n * factorial_of_a_number($n-1);
    }
	}
print_r(factorial_of_a_number(4)."\n");
?>

Sample Output:

24

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now