<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript">
function factorial(n){
if(n==1){
return 1;
}
return n*factorial(n-1);
}
window.onload=function(){
vor oBtn=document.getElementById("btn");
vor p_d=document.getElementById("put_data");
vor o_d=document.getElementById("out_data");
oBtn.onclick=function(){
o_d.value=String(factorial(Number(p_d.value)));
}
}
</script>
</head>
<body>
<h3>阶乘</h3>
<br/>
<p><input type="text" value="0" id="put_data">的<input type="button" value="阶乘" id="btn">为:<input type="text" value="1" id="out_data"></p>
</body>
</html>