when finding complexity, generally its the loops which are counted and constant expressions are discarded.
so, broadly it would be O(n) as you said.
But if you want to find tune and take constants in consideration, you have to look what is the time complexity of other functions you used inside the loop, like string::at, string::erase etc..
for non critical code, just considering the loops would be good.
The first call does N calls in a loop. Each of those does N-1 calls in their loops. The next level does N-2 calls, and so forth. That does sound like a lot more than linear.
This is why discrete math is a thing. To handle issues like this. Most of the time in the real world, finding all permutations of something just isn't feasible.
I was wrong and ResidentBiscuit right. I really didn't look into it.
Saaume, that size of string is N;
When you call your function and loop will execute N times. Each time it will call your function with lenght of N-1; each of that call will loops N-1 times — N·(N−1) loops now. Each of level 2 loops will call function with lenght of N-2 — N·(N−1)·(N−2) loops. And so on in the end we have N·(N−1)·(N−2)·...·3·2·1 loops or N! loops. Each of those loops has constant complexivity and so total complexivity is O(N!)