四叶玫瑰数

四叶玫瑰数是指四位数各位上的数字的四次方之和等于本身的数。(参考水仙花数)

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>四叶玫瑰数</title>
<script>
for(var n=1000;n<10000;n++){
var a=parseInt(n/1000);
var b=parseInt(n%1000/100);
var c=parseInt(n%100/10);
var d=n%10;
if(Math.pow(a,4)+Math.pow(b,4)+Math.pow(c,4)+Math.pow(d,4)==n){
console.log(n);
}
}
</script>
</head>
<body>

</body>
</html>


 
 
posted @ 2018-04-05 09:26  Daisy0331  阅读(2100)  评论(0编辑  收藏  举报