<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form action="" method="post">
<input type="text" id="narcissus" placeholder="请输入100-999以内水仙花数!"/>
<input type="button" value="判断" onclick="judge()"/>
</form>
<div id="pd">
</div>
<script type="text/javascript">
function judge(){
let pd='';
document.getElementById('pd').innerHTML=pd;
let sum=0;
for (let narcissus = 100; narcissus < 1000; narcissus++) {
narcissus=parseInt(narcissus);
Individual=narcissus%10;
Ten=parseInt(narcissus/10%10);
Hundred=parseInt(narcissus/100);
if(narcissus==((Individual*Individual*Individual)+(Ten*Ten*Ten)+(Hundred*Hundred*Hundred))){
sum+=narcissus;
console.log(sum);
}
}
document.getElementById('pd').innerHTML=sum;
}
</script>
</body>
</html>
09-15
740