Answers for "php program to find factorial of a number using function"

PHP
1

php factorial

function Factorial($n) {
  	return ($n <= 1) ? 1 : $n * Factorial($n - 1);
}
Posted by: Guest on April-22-2021
0

php program to find factorial of a number using function

function Factorial($number){ 
    if($number <= 1){   
        return 1;   
    }   
    else{   
        return $number * Factorial($number - 1);   
    }   
} 
  
$number = 5; 
$fact = Factorial($number); 
echo "Factorial = $fact";  //output : 120
?>
Posted by: Guest on October-16-2020
0

php program to find factorial of a number using function

<?php
function Factorial($number){ 
    if($number <= 1){   
        return 1;   
    }   
    else{   
        return $number * Factorial($number - 1);   
    }   
} 
  
$number = 5; 
$fact = Factorial($number); 
echo "Factorial = $fact";  //output : 120
?>
Posted by: Guest on March-27-2021

Code answers related to "php program to find factorial of a number using function"

Browse Popular Code Answers by Language