<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>Document</title> </head> <body> <script src="./b.js"></script> </body> </html>
function daffodils() {
let arr = [];
for (let i = 100; i <= 10000; i++) {
let qian = parseInt((i/1000)%10);
let bai = parseInt((i / 100)%10);
let shi = parseInt((i / 10) % 10);
let ge = parseInt(i % 10);
if (i == (qian ** 3 + bai ** 3 + shi ** 3 + ge ** 3)){
arr.push(i);
}
else if (i == (qian ** 4 + bai ** 4 + shi ** 4 + ge ** 4)){
arr.push(i);
}
}
return arr;
}
document.write(daffodils());
![](/i/l/?n=23&i=blog/3126046/202305/3126046-20230510224540328-1502414743.png)
标签:输出,10000,递归,let,100,水仙花 From: https://www.cnblogs.com/2596148460LW/p/17389585.html