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).

It's a mathematical error if x=0 and n<0. My code just return 0 for every x=0 and was accepted

According to 'My code just return 0 for every x=0 and was accepted', I believe you miss the test case x = 0, n = 0, not x=0, n<0.

x = 0, n = 0

x=0, n<0

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