factorial

Benchmark created by Eduardo Peredo on


Test runner

Ready to run.

Testing in
TestOps/sec
recursive
var random = parseInt(Math.random() * 100)

function factorial (num){
	if (num == 1 || num <= 0) {
		return 1
	}else{
		return num*factorial(num-1);
	}
}

factorial(random);
ready
loop
var random = parseInt(Math.random() * 100)

function factorialLoop(num) {
var result = 1;
for(var i = 1; i < num; i++) {
  result = (result * (i + 1));
}
return result;
}

factorialLoop(random);
ready

Revisions

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

  • Revision 1: published by Eduardo Peredo on