. . .

Get a number of input from the user and print its factorial

javascript
Please share the article
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Using javascript you can find factorial of any number, here the same logic is applied like c language.

Enter Num: <input id="num">
<button onclick="show()">Factorial</button>
<input id="answer">
function show(){

var i, no, fact;
fact = 1;
no = (document.getElementById("num").value);
for(i=1; i<=no; i++)  
{
fact= fact*i;
}  
document.getElementById("answer").value= fact;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

20 − eight =