I wrote this test code trying to work out a problem. The code gives the correct answer for the example (zero) but to understand the problem i need to understand what the code is doing on a sort of step by step basis. In other words how to do it with a pen and paper.

The answer is 3240 i just don't know why. Can anyone help?

```
#include <iostream>
using namespace std;
int fun(int n);
int a=50;
int b=2000;
int c=40;
int main()
{
cout<<fun(0)<<endl;
return 0;
}
int fun(int n)
{
if(n>b) return n-c;
if(n<=b) return fun(a+fun(a+fun(a+fun(a+n))));
}
```