Objective
In how many different ways can an amount be formed with coins of certain values, with as many coins of each as you want? Here combinations are counted (1+2 is the same as 2+1). The order of the loops decides whether combinations or sequences are counted.
Instructions
- The first line has the amount (integer ≥ 0) and the second the coin values.
- Show
Ways: nwith the number of combinations.
5
1 2 5
Ways: 4
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise