<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript">
var num = [];
var j = 0;
for(var i = 100; i < 1000; i ++){
var iG, iS, iB;
iG = i % 10;
iS = parseInt(i / 10) % 10;
iB = parseInt(i / 100);
var sum = iG*iG*iG + iS*iS*iS + iB*iB*iB;
if(i == sum){
num[j] = i;
j ++;
}
}
document.write("水仙花数都有:" + "<br />");
for(var i = 0; i < num.length; i ++){
document.write(num[i] + "<br />");
}
</script>
</head>
<body>
</body>
</html>
时间: 2024-10-29 21:04:14