title: Finding Factorial of a number through prompt from the user
body: <p>I have been struggling with the this output from which hangs my browser. When I run the following code it runs fine.</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;script type="text/javascript"&gt;
  var input = 5;
  for(var i=1;i&lt; 5;i++){
  input = i*input;
  }
  document.write(input);
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>But this hangs the browser and I have to stop it finally. I cant't find any bug or error in this code.</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt; 
  &lt;/head&gt;
  &lt;body&gt;
  &lt;script type="text/javascript"&gt;
      var input = prompt("Enter the number to get factorial of: ");
      var result = input;
      for(var i=1;i &lt; input;i++){
         result = i * result;
      }
      document.write(result);
     &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>