factorial recursive vs not recursive (v5)

Revision 5 of this benchmark created by KooiInc on


Preparation HTML

<script>
  /* recursive */
  
  function factorial(n) {
   var result = 1,
       fac = function(n) {
     return result *= n, n--, (n > 1 ? fac(n) : result);
       };
   return fac(n);
  }
  
  /* non recursive */
  
  function factorialnr(n) {
   var r = n;
   while (--n > 1) {
    r = r * n;
   }
   return r;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
recursive
factorial(50)
ready
non recursive
factorialnr(50)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.