Total number of ways to count the possible combination for coin
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/4243831/how-to-count-possible-combination-for-coin-problem">How to count possible combination for coin problem</a>  </p>
</blockquote>



<p>In this case suppose the amount is 15 and coins are 1, 6, 7 then total number of ways to it is 6. Below code works fine but its not that much efficient. Any suggestions will be appreciated.</p>

<pre><code>public class CoinProblem {

    public static void main(String[] args) {
        int amount = 15;
        int coinTypes[] = {1,6,7};


        int combinations = 0;
        for (int i = 0; i * 7 &lt;=15; i++) {
            for (int j = 0; j * 6 + i * 7 &lt;= 15; j++) {
              combinations++;
            }
        }
        System.out.println(combinations);


    }
}
</code></pre>
