题目:一个整数,它加上100后是一个完全平方数,加上168又是一个完全平方数,请问该数是多少? (0-1000之内判断)
代码:
/**
* 开方
* @author cheng
*
*/
public class Thirteen {
public static void main(String[] args) {
long k=0;
for(k=1;k<=100000l;k++) //math.floor(x)返回小于参数x的最大整数
if(Math.floor(Math.sqrt(k+100))==Math.sqrt(k+100) && Math.floor(Math.sqrt(k+168))==Math.sqrt(k+168))
System.out.println("这个数为:"+k);
}
}
输出结果:
这个数为:156