Do you mean that when the input is 5, then the output is
5!=5*4*3*2*1=120
You can break that line into three parts:
1. The prefix (5!=)is printed before the loop.
2. The body (5*4*3*...) adds up during the loop.
3. The suffix (=120\n) shows after the loop.
You still print everything on line 12 and on every iteration too. Why did you actually add stuff to line 12, rather than take out some?
I told you to print in pieces and my example has three separate calls to printf that together form one line to stdout. If you look carefully at my three fprint calls you should see that they are all different and print different things.
The random values that my example happens to use have nothing to do with your problem.