unexpected output in recursive function - c++ : I am trying to find the output for fun(5). But I am getting wrong answer, don't know why. My doubt is for n =5 for instance, it would return fun(3) + 3. After that would the return fun(4) + x work or the function fun will be called again?

    int fun(int n)
    {
       static int x = 0;
       if (n<=0) return 1;
       if (n>3)
       {
         x = n;
         return fun(n-2) + 3;
       }
       return fun(n-1) + x;
    }