factorial

by legolandbridge

JavaScript

function factorial(x){
  if(x<2){return x;}
  return x*factorial(x-1);
}

alert(factorial(4));