StackOverflow in "submit solution" but not in "run code" for question "pow(x,n)"

My code below:
test case is : x = 1.00001 n = 123456
if I click "run code", my answer is the same as the expected result, which is "3.43684"
if I click "submit solution" , I receive a runtime error of stack overflow.
What's going on with the two buttons?

class Solution {
    public double myPow(double x, int n) {
        if(x<0 && n<0){
            return 0;
        }
        if(n<0){
            return myPow(1/x,0-n);
        }
        else if(n==0){
            return 1;
        }
        
        else{
            return x*myPow(x,n-1);
        }
    }
}
Comments (2)