novicer,
<script>
var input = 5//prompt("Введите число: ");
input = parseInt(input);
function factorial(x) {
if (x <= 1)
return 1;
var result = 1;
for(var i = x; i;) {
result *= i--
}
return result;
}
document.write("Факториал " + input + "! = " + factorial(input));
</script>