I checked the question. You need to simulate the procedure with coins 4 - n for which your coin value increase and keep a max count. If the value decrease stop processing.
You code simulate the procedure for only 1 iteration. You need to repeat iterations as long as you can increase your value. If value remains same or decreases, stop it.
This looks like an infinitely recursive solution. But using memoization, you can make the things feasible. Please try it yourself, if you find it difficult to grasp, check editorials or others solution. If not understood something, please post.