Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php factorial

function Factorial($n) {
  	return ($n <= 1) ? 1 : $n * Factorial($n - 1);
}
Comment

factorial 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
?> 
Comment

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
?>
Comment

factorial program in PHP

<?php
$no= 7;  
$fact= 1;  
$a=$no;
for($a=$no; $a>=1; $a--)  
{  
  $fact= $fact* $a;  
}  
$msg="Factorial of $no is $fact";  
?>  
<p style="color:#66CC00;font-size:40px;font-family:Mistral;">
<?Php if(isset($msg))
{
echo $msg;
} ?>
</p>
Comment

PREVIOUS NEXT
Code Example
Php :: laravel restrict route 
Php :: wordpress get post date custom format 
Php :: where clause in laravel 
Php :: laravel url with parameters blade 
Php :: laravel get biggest id 
Php :: laravel-enum 
Php :: append in php 
Php :: laravel migration column types 
Php :: php docker offical apache 
Php :: get array of last 3 dates with carbon 
Php :: update url wordpress 
Php :: how to use union and intersection in laravel query 
Php :: execute php mysql securely 
Php :: laravel collection to array 
Php :: how to get the previous page url in php 
Php :: php method type hinting 
Php :: php api 
Php :: php explode sentence into words 
Php :: laravel check if environment is production 
Php :: change php version on ubuntu 
Php :: laravel controller middleware example 
Php :: ErrorException symlink(): No such file or directory 
Php :: phpmyadmin export database 
Php :: joomla print query 
Php :: laravel migrate error default character 199 boot 
Php :: laravel view routes 
Php :: laravel email validation 
Php :: acf get all choices from select 
Php :: get 2 hrs before data in php 
Php :: twig filter array 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =