Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

Factorial In JavaScript with do while loop

Table of Contents

Factorial In JavaScript with do while loop

<html>
<head>
<link rel="stylesheet" type="text/css" href="../style.css">
<script>
function show(){

var i=1, no, fact;
fact=1;
no=Number(document.getElementById("num").value);
do
    {
        fact=fact*i;
        i++;
		
    }
	while(i<=no);
	
	document.getElementById("answer").value= fact;
	}
	
</script>
</head>
<body class="buttonhome">
Enter Num: <input id="num"></br></br>
<button class="buttonhome" onClick="show()">Factorial</button>
<input id="answer">
</body>
</html>
Prof. Fzal Rehman Shamil
Instructor, Researcher, Blogger, SEO Expert, Poet and Publisher of International Journal Of Software, Technology & Science ISSN : 2616 - 5325