Sunday, 25 January 2015

Javascript program to calculate/find factorial of n number,until entered 0.

<!--Program to calculate factorial of n number, until entered 0-->

<html>
<head>
<title>Javascript</title>
<script type="text/javascript">
var a=1;
for(;n!=0;)
 {
  n=1;
  var n=prompt("Enter a number to calculate its factorial");
  {
   for(var i=1;i<=n;i++)
   {
    a=a*i;
    document.write(a+" ");
   }
   document.write("<br/> ");
   a=1;
  }
  document.write(" ");
 }
</script>
</head>
<body>
</body>
</html>

No comments:

Post a Comment

Read contacts in iOS using Swift with error handling

Just copy and paste the below code Pre-step before pasting the below code Add below line in AppDelegate.swift file below import statement ...