Advertisements
Advertisements
Question
Write event driven JavaScript program for the following.
Find and display factorial of given number.
Answer in Brief
Solution
Coding:
<html>
<script type="text/javascript">
var n=4,i,f=1;
for(i=n;i>= 1;i--)
{
f=f*i;
}
document.write("<br>Factorial of 4 is"+f);
</script>
</html>
shaalaa.com
DOM (Document Object Model)
Is there an error in this question or solution?