JSFiddle - React, Tailwind, and code Playground

by Progo

HTML

<script src="http://jhs.iriscouch.com/demo/_design/bigdecimal/bigdecimal.js"></script>
Increase the accuracy for more accurate digits of <i> e.</i>
<form name='eCalc' action='' method='post'>
   <input type='text' readonly='readonly' name='result' placeholder='e' />
   <input class="br" type='number' name='num' placeholder='accuracy' />
   <input class="br" type='button' id='calc-button' name='submit' value='Calculate' />
   <div id='time'></div>
</form>

CSS

body{
    font-family: Helvetica, arial, sans-serif;   
    color: #444;
    margin: 10px;
}
form{
    padding: 10px;
    border-radius: 20px;
    background-color: #ccc;
    border: 1px solid #aaa;  
    display: block;
    margin-top: 20px;
    margin-left: 20px;
    width: 350px;
}
form > input{
    padding: 10px;
    font-size: 1.2em; 
    margin: 10px;  
    width: 310px;
}

form > input#calc-button{
    background:none; 
    border:none;    
    cursor: pointer;
    background-color: #4A8CFF;
    color: white;
    border-radius: 5px;    
}

form > input#calc-button:hover{
     background-color:#2867D4;   
}
form > #time{
     font-family: Helvetica, arial, sans-serif;  
     margin-left: 5px;
     color: #666;   
     font-size: .9em;        
}

JavaScript

// e calc
/*
|| formula =
||
||		 	∞
||		   ____
||		   \	(3k)^2 +1
||	e =    /	---------
||		   ____    (3k)!
||		   k = 0
||
*/ 

/* old factorial function code:
var f = [];
function factorial (n) {
  if (n == 0 || n == 1)
    return 1;
  if (f[n] > 0)
    return f[n];
  return f[n] = factorial(n-1) * n;
};
*/

window.



var eCalc = {
    calculate: function(){
        var steps = document.eCalc.num.value;
        if(steps < 100001){
            return this.calc(steps);
        } else if( steps > 100000){
            var c = confirm("This may lag you computer to death…\nAre you site you would like to proceed?");                                  
            if(c == true){
                return this.calc(steps);
            };
        };
    },
    calc: function(terms){
        var start_time = Date.now(),
            e = 0,
            d,
            n;
        for(i = 0; i < terms; i++){
            /*n = Math.pow(3 * i, 2) + 1;
            d = factorial(3 * i);
            e = e + (n / d);*/
            n = math.add(math.pow(math.multiply(3, i), 2), 1);
            d = math.factorial(math.multiply(3,i));
            e = math.add(e, math.divide(n, d));
        };
        var end_time = Date.now(),
            total_time = end_time - start_time;
        if(total_time >= 1000){
            total_time = (total_time/1000)+"seconds";
        }else{
            total_time += "ms";
        };
        document.eCalc.result.value = e;
        document.getElementById('time').innerHTML = "Result calculated in: " + total_time + "...";
    }
};
document.getElementById("calc-button").addEventListener("click", function(e){
    e.preventDefault();
    eCalc.calculate();    
}, false);
// big.js: