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 would implement the function like so:
bool IsWholeNumberPower(int x, int y) { double power = log(x)/log(y); return floor(power) == power; }
This shouldn't need check within a delta as is common with floating point comparisons, since we're checking whole numbers.