What is wrong in my code?


#1

public class Solution {
public int isPower(int A) {
if(A == 1)
return 1;
for(int i=2;i*i<=A;i++)
{
double baseLog = Math.log(A)/i;
int base = (int)Math.exp(baseLog);
if(Math.abs(Math.pow(base,i)-A) < 0.00001)
{
return 1;
}
}
return 0;
}
}


#2

Increase the number of zeros 0.00000001. this will work.


#3

Thanks man. That helped.