Σn!=1!+2!+......+n!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>海鲜</title>
</head>
<body>
<p>
输入n:<input id="num1">
</p>
<p>
求Σn!<input id="num2" readonly>
</p>
<p>
<button onclick="sum()">计算</button>
<button onclick="ex()">取消</button>
</p>
<script>
function sum(){
let num=document.getElementById("num1").value;
var sum1=0,i=1,j=1,k=1;
for(i=1;i<=num;i++){
k=k*i;
sum1=sum1+k;
}
document.getElementById("num2").value=sum1;
}
function ex(){
document.getElementById("num1").value=null;
document.getElementById("num2").value=null;
}
</script>
</body>
</html>