Calculate the value of e

This program calculates the value of e.

function ecalc(times) {
   x=1;
   e_value=0;
   while (x<times+1) {
      new_value=0;
      num=0;
      while (num<1) {
         num=num+Math.random();
         new_value=new_value+1;
      }
      e_value=(e_value*(x-1)+new_value)/x;
      x=x+1;
   }
   alert("The value of e you calculated is: " + e_value + ".");
}


Button does not work.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License