有些数字的立方的末尾正好是该数字本身。
比如:1,4,5,6,9,24,25,....
请你计算一下,在10000以内的数字中(指该数字,并非它立方后的数值),符合这个特征的正整数一共有多少个。
int count = 0;
for (int i = 1; i < 10001; i++) {
String t = ""+(long)Math.pow(i, 3);//必须long
if (t.endsWith(""+i)) {//判断末尾是否为本身
System.out.println(i);
count++;
}
}
System.out.println(count);//36