title: Greedy Coin Change Time Complexity
body: <p>I'm trying to figure out the time complexity of a greedy coin changing algorithm. (I understand Dynamic Programming approach is better for this problem but I did that already). I'm not sure how to go about doing the <code>while</code> loop, but I do get the <code>for</code> loop.</p>
  
  <p>I have the following where <code>D[1...m]</code> is how many denominations there are (which always includes a 1), and where <code>n</code> is how much you need to make change for.</p>
  
  <p>This is my algorithm:</p>
  
  <pre><code>CoinChangeGreedy(D[1...m], n)
      numCoins = 0
      for i = m to 1
          while n ≥ D[i]
              n -= D[i]
              numCoins += 1
      return numCoins
  </code></pre>