Help with COINS


I’m attempting this problem(Code: COINS). This is my solution:

Can anyone tell me what I am doing wrong?

My logic is: if the sum of n/2+n/3+n/4 is bigger than n, then substitute n by that sum, otherwise, print n.

How many maximum coins can you get for n=24?
I can get 27.
You exchange 24 for 12+8+6=26.
Then you exchange the 12 coin for a 13 coin.

Think about it.

Let’s say your answer is given by f(n).


1 Like

Thanks, I understand my mistake now. :slight_smile:

1 Like