Factorial of number in JavaScript


Prev Tutorial Next Tutorial

Find Factorial of number in JavaScript

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

you only need to write your javascript code inside <script> ..... </script> tag using any editor like notepad or edit plus. Save below code with .html or .htm extension. No need to compile your javascript code just open your code in any web browser.

Find factorial of number using JavaScript

Example Factorial of any number

<!doctype html>
function show(){

var i, no, fact;
for(i=1; i<=no; i++)  
fact= fact*i;
document.getElementById("answer").value= fact;
Enter Num: <input id="num">
<button onclick="show()">Factorial</button>
<input id="answer">


Enter Num:

Code Explanation

  • no=Number(document.getElementById("num").value);
    This code is used for receive input value form input field which have id num.
  • document.getElementById("answer").value= fact;
    This code is used for receive calculated value of factorial and display in input field which have id answer
  • <button onclick="show()">Factorial</button>
    This code is used for call show function when button clicked.

Prev Tutorial Next Tutorial


Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 8076671483

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

Download Projects

Google Advertisements

Buy Websites 9999595223

Buy Fresh and Payment Receive Media.net Account with Website. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs