title: How to calculate coins combination for an amount of change money?
body: <p>I'm trying to create a change program in Delphi/Pascal. I have the values $0.05, $0.10, $0.20, $0.50, $1.00 and $2.00, and an unknown amount x. I need to be able to give the amount of coins per denomination that makes up x amount. Unlimited amount of coins of any denomination, it doesn't matter about that bit.</p>
  <p>I have tried this for 5 days, but for the life of me, I have nothing to show for it. I've tried dynamic arrays, I've tried <code>for</code> (array) <code>do</code>, but it's just not working for me. If you can put me on the right track, that would be great!</p>
  <h3>Update:</h3>
  <p>OK, I have worked on it, but now I'm getting some issues that I can't figure out, which was part of the issue in the first instance. I keep getting the issue that it doesn't like my &quot;coins&quot;. I tried to set it as an array, and it doesn't like that, I tried it as a constant array and then it didn't like that, I even tried it as a set, and that didn't work. This should work, but I've missed something. Any ideas would be great!</p>
  <pre><code>var
    Form1: TForm1;
    i : integer;
    change : integer;
    coins : double;
    coinage : integer;
  begin
    coins := (0.05, 0.10, 0.20, 0.50, 1.00, 2.00);
    change := 4.00;
    while change &gt; 0 do
      coinage := trunc(change/coins);
      change := change-coinage*coins;
      i := change - 1;
      while change&gt;=1 do
      begin
        coinage := 0;
        i := coinage-1;
      end;
    end;
  </code></pre>