I was looking for a good solution to the Change-making problem and I found this code(Python):
target = 200
coins = [1,2,5,10,20,50,100,200]
ways = [1]+[0]*ta
The solution that you posted is summarized version of this code.
///
/// We are going to fill the biggest coins one by one.
///
/// the amount of money
public static void MakeChange (int n)
{
int n1, n2, n3; // residual of amount after each coin
int quarter, dime, nickel; // These are number of 25c, 10c, 5c, 1c
for (quarter = n/25; quarter >= 0; quarter--)
{
n1 = n - 25 * quarter;
for (dime = n1/10; dime >= 0; dime--)
{
n2 = n1 - 10 * dime;
for (nickel = n2/5; nickel >= 0 && (n2 - 5*nickel) >= 0; nickel--)
{
n3 = n2 - 5 * nickel;
Console.WriteLine("{0},{1},{2},{3}", quarter, dime, nickel, n3); // n3 becomes the number of cent.
}
}
}
}