google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: Write a php program to print factorial of a number

Tuesday, April 7, 2020

Write a php program to print factorial of a number

Write a php program to print factorial of a number:
Answer:

$num = 7; 
$factorial = 1; 
for ($x=$num; $x>=1; $x--) 

  $factorial = $factorial * $x; 

echo "Factorial of $num is $factorial"; 
?>


Output:

Factorial of 7 is 5040

No comments:

Post a Comment

शिव भोलेनाथ स्तुति

 जय शिवशंकर, जय गंगाधर, करुणा-कर करतार हरे,   जय कैलाशी, जय अविनाशी, सुखराशि, सुख-सार हरे जय शशि-शेखर, जय डमरू-धर जय-जय प्रेमागार हरे,   जय ...