PHP program to find factorial using while loop

Code


<html>
<head>
<title>FACTORIAL OF A NUMBER</title>
</head>
<body>
<font size=5>FACTORIAL OF A NUMBER</font>
<br/>
<br/>
<form action=factorial.php method="post">
ENTER A NUMBER:<input type="text" name="t1">
<br><br>
<input type="submit" value="FACTORIAL">
<?php
if(isset($_POST["t1"]))
{
$n=$_POST["t1"];
$fact=1;
echo "<br/>
<br/>";
echo "Factorial of $n is: ";

while($n>0)
{
$fact=$fact*$n;
$n--;
}
echo "$fact";
}
?>
</form>
</body>
</html>

Output



PHP program to find factorial using while loop
PHP program to find the factorial of a number

3 comments:

Anonymous said...

Factorial of a number in php

Xplore IT Corp said...

Hey Nice Blog!! Thanks For Sharing!!!Wonderful blog & good post.Its really helpful for me, waiting for a more new post. Keep Blogging!
best java training in coimbatore
php training in coimbatore
best php training institutes in coimbatore

pranisha said...

Infycle Technologies, the No.1 Cloud training center offers attractive AWS Training in Chennai with the remunerative DevOps Course for the candidate. Along with the courses, 100% placement training guidance will also be given for the welfare of your career. For more, reach out to us by calling 7502633633.