PHP program to calculate factorial of a number
<html>
<body>
<title>Factorial of a number</title>
<form action="" method="post">
<input type="text" name="number" size="2" />
<input type="submit" />
</form>
</body>
</html>
<?php
if($_POST)
{
$fact=1;
$number = $_POST['number'];
echo "Factorial of $number: <br><br>";
for($i = 1; $i <= $number; $i++)
{
$fact = $fact * $i;
print $fact. "<br>";
}
}
?>
<body>
<title>Factorial of a number</title>
<form action="" method="post">
<input type="text" name="number" size="2" />
<input type="submit" />
</form>
</body>
</html>
<?php
if($_POST)
{
$fact=1;
$number = $_POST['number'];
echo "Factorial of $number: <br><br>";
for($i = 1; $i <= $number; $i++)
{
$fact = $fact * $i;
print $fact. "<br>";
}
}
?>
No comments:
Post a Comment