Tuesday, October 22, 2019

Factorial of a Number in PHP

I wrote a program that will ask the user to give a number and then the program will compute the factorial value of the given number using PHP as my programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking and Arduino Project development at a very affordable price.


]
Sample Program Output


Program Listing

index.php

<!DOCTYPE html>
<html>
<head>
 <title>Factorial of a Number in PHP</title>
</head>
<body>
  <style>
    body {
    font-family: arial;
    font-size:14;
    } 
</style>
<h2>Factorial of a Number in PHP </h2>
<table>
<form name="factorial" method="post">
<tr>
<td>Enter a Number : </td>
<td><input type="text" name="num" required autofocus></td>
</tr>
<tr>
<tr></tr>
<tr></tr>
<td><input type="submit" value="Check" name="submit" /> </td>
</tr>
</form>
</table><br>
<?php

 if (isset($_POST['num']))
 {
  $num=$_POST['num'];
  $fact=1;

  for ($i=$num; $i>=1; $i--)
  {
  $fact = $fact * $i;
  }

  echo "The Factorial Value of $num is $fact.";
 }
 ?>
</body>
</html>


No comments:

Post a Comment