算法题——统计四叶玫瑰数的个数

public static int fourMi(){
int count = 0;
for (int i = 1000; i < 9999; i++) {
int ge = i % 10;
int shi = i / 10 % 10;
int bai = i / 100 % 10;
int qian = i / 1000 % 10;

double sum = Math.pow(ge, 4) + Math.pow(shi, 4) + Math.pow(bai, 4) + Math.pow(qian, 4);
if(sum == i){
count++;
System.out.println(i);
}
}
return count;
}
结果是只有3个,1634,8208,9474。
posted @ 2023-09-18 21:19  叫金克丝爆爆  阅读(152)  评论(0)    收藏  举报