php program to find factorial of a number
Below given a simple php program with form to find factorial of a given number.
CODE :
<?php
$num=$_REQUEST['a'];
$fact = 1;
for($i = 1; $i <= $num ;$i++)
$fact = $fact * $i;
$res= $fact;
?>
<form action="" method="post">
<table width="50%" border="1">
<tr>
<td colspan="2" align="center"> <?php echo $res;?></td>
</tr>
<tr>
<td>SELECT NUMBER </td>
<td><input type="text" name="a" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="go" value="Submit" /></td>
</tr>
</table>
</form>
No comments:
Post a Comment