This is an interview question: \"Given 2 integers x and y, check if x is an integer power of y\" (e.g. for x = 8 and y = 2 the answer is \"true\", and for x = 10 and y = 2 \
I found this Solution //Check for If A can be expressed as power of two integers
int isPower(int A) { int i,a; double p; if(A==1) return 1; for(int a=1; a<=sqrt(A);++a ) { p=log(A)/log(a); if(p-int(p)<0.000000001) return 1; } return 0; }
binarycoder.org