# Time-complexity of recursive defined code [duplicate]

How would I set up a recursive formula for time-complexity for this code:

int b(int n, int x) {
int erg = x;
if (n>1) {
for (int i = 1; i <= n; i++) {
erg = erg+i;
}
for (int k=0; k<3; k++) {
erg = erg + b(n/3,erg/9);
}
}
return erg;
}


Is my assumption correct, that it would be something like this? $$T(n)=n(T(\tfrac{n}{3})+n)$$

But how to deal with the if statement and the second for loop, since it is independent of $n$?

The time complexity depends only on $n$ but not on $x$. You can assume $T(n)$ denote the time complexity. For $n\leq 1$, $T(n)=O(1)$ apparently. For $n>1$, the first for-loop takes $O(n)$ time and the second for-loop takes $3T(n/3)$ time since it calls $b(n/3,\cdot)$ three times.