What is the time complexity of this piece of code?
Let $f(n)$ be the answer for an input of size $n$.
then we have the following equation:

$f(n) = f(n - 1) + (n - 1)! * n = f(n - 1) + n!$

That's because you call the function for an input of size $n - 1$ which gives $f(n - 1)$, then you iterate over all permutations of size $n - 1$ which there are $(n -  1)!$ such permutations, and then you iterate over the position of the new element, which there are $n$ such positions. This gives us:

$f(n) = [\sum_{i=1}^n i!] &lt; (n + 1)!$

You can easily prove this by induction.
So $f(n) = O((n + 1)!)$.