函数-函数递归

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
计算阶乘
function factorial(n) {  
  if (n === 0) {  
    return 1;  
  }  
  return n * factorial(n - 1);  
}
factorial(100)
ready
计算阶乘(尾递归)
function factorial(n, result = 1) {  
  if (n === 0) {  
    return result;  
  }  
  return factorial(n - 1, result * n);  
}
factorial(100)
ready

Revisions

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