Use log to check if number is

interview-questions
facebook
high-level-design
Tags: #<Tag:0x00007f2427f3caa8> #<Tag:0x00007f2427f3c968> #<Tag:0x00007f2427f3c800>

#1

Comment body goeint Solution::isPower(int A) {
if(A==1)
return 1;
for(int i=2;i<100000;i++)
{
float a=log(A)/log(i);
int b=a;
float c=b;
if(c==a and c!=1)
return 1;
}
return 0;
}s here.