自守数

自守数是指一个数的平方的尾数等于该数自身的自然数。例如:25^2 = 625,76^2 = 5776,9376^2 = 87909376。请求出n以内的自守数的个数

public static void main(String[] args) {

for (int i = 0; i < 100; i++) {
boolean zishou = isZishou(i);
if(zishou){
System.out.println("i:"+i+", 是自守数");
}
}
}

private static boolean isZishou(int n) {
String num = n * n + "";
String two = n + "";
return num.endsWith(two);

}
原文地址:https://www.cnblogs.com/dongma/p/13232678.html