The hole issue is about how you are addressing the problem(IMHO)
a number x can be rooted to a base n if:
the x^(1/n) is an integer, where n > 0
therefore the approach could be:
public static void main(final String[] args) {
for (int i = 1; i <= 10; i++) {
System.out.println(" has " + i + " exactly a root base2(square)? " + isRootInteger(i, 2));
System.out.println(" has " + i + " exactly a root base3(cubic)? " + isRootInteger(i, 3));
}
}
public static boolean isRootInteger(int number, int root) {
double dResult = Math.pow(number, 1.0 / root);
if ((dResult == Math.floor(dResult)) && !Double.isInfinite(dResult)) {
return true;
}
return false;
}