Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

When printing out the value of some calculation:

log(243)/log(3) gives 5

floor(log(243)/log(3)) gives 4

floor(5) gives 5

Why???

I tried in python 2.7.10. I think the result is the same in c++.

In [2]: import math

In [3]: math.log(243) Out[3]: 5.493061443340548

In [4]: math.log(3) Out[4]: 1.0986122886681098

In [5]: math.log(243)/math.log(3) Out[5]: 4.999999999999999

Maybe you can try "round" instead of "floor".

It possibly turns out to be 4.9999999999 due to round off errors in floating point arithmetic, floor() of which is 4.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.