Showing posts with label factorial in javascript. Show all posts
Showing posts with label factorial in javascript. Show all posts

Friday, January 26, 2018

Factorial Number Solver in JavaScript

A program that I wrote using JavaScript that will ask the user to give a number and then our program will compute it's factorial equivalent value. The code is very simple and easy to understand.

I am currently accepting programming and web development work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.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 is (034) 4335675.






Sample Program Output


Program Listing

factorial.htm

<!doctype html>
<html>
<head>
<style>

   .art {

      font-family: arial;
      font-weight: bold;
      color:red;
      text-align: center;
      width:55%;
      background-color:yellow;
   }

.art2 {

      font-family: arial;
      font-weight: bold;
      font-size: 25px;
      color:blue;
      text-align: center;
      width:45%;
      background-color:lightgreen;
   }

   body {
     font-family: arial;
     font-weight: bold;
     font-size: 20px;
   }

   #button_me {
    background-color: #008CBA;
    font-family: arial;
    font-weight: bold;
    font-size: 20px;
    height: 50px;
    width: 120px
     text-align: center;
    cursor: pointer;
 }

 input[type=text] {
    font-family: arial;
    font-weight: bold;
    font-size: 20px;
   
 }
</style>
  
    
<script>
function palindrome_number()
{
var i, no, fact;

no=Number(document.getElementById("no_input").value);

fact=1;
for(i=1; i<=no; i++)  
{
fact= fact*i;
}  

 document.getElementById("msg").innerHTML = "The factorial value of  "+ no + " is " +fact + ".";

}
</script>

<script>
function clear_me()
{
document.getElementById("msg").innerHTML = "";
document.getElementById("no_input").value = "";
document.getElementById("no_input").focus();
}
</script>

</head>
<body>
<h1 class="art"> Factorial Number Solver in JavaScript </h1>
    <p  class="art2"> Created By Mr. Jake R. Pomperada, MAED-IT </p>
<br><br>
Give a Number : <input id="no_input" type="text" autofocus required>
<br><br>
<p id="msg"> </p> 
<button id="button_me" onclick="palindrome_number()">Check Number</button>
&nbsp;&nbsp;&nbsp;
<button id="button_me" onclick="clear_me()">Clear</button>
</br></br>
</body>
</html>