Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 9
    You need to be careful of rounding issues with floating point numbers. Also how does isPower(-8, -2) fair? Commented Dec 13, 2010 at 13:25
  • Yes, you are right. I thought integer is positive. Then, I should think it's abs version Commented Dec 13, 2010 at 13:43
  • You should try isPower(1162261467, 3) x is greater one (int the question) Commented Dec 13, 2010 at 13:46
  • 1
    +1 nice way, but, It's not O(1), Is O(log(x) + log(y)), Also using decimal is better to avoid rounding problems. Commented Dec 17, 2010 at 15:14
  • I think your code fails for (17, -2). (You can correct it though). Commented Aug 13, 2016 at 22:04