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

अच्छे विचार करे विचार

  पहचान की नुमाईश, जरा कम करें... जहाँ भी "मैं" लिखा है, उसे "हम" करें... हमारी "इच्छाओं" से ज़्यादा "सुन...