English

Write event driven JavaScript program for the following. Find and display factorial of given number. - Information Technology

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?
Chapter 3: Advanced Javascript - Exercises [Page 52]

APPEARS IN

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×