The basic algorithm is take the largest denomination, divide the pot by it, throw away the remainder, and that's your chip count for that denom. The subtract the chip count * denom from the pot. Then repeat with the next-highest denom, until finished.
As for the Result[7,5] thing, it could be easily implemented in Javascript as follows:
var denoms = [1, 5, 10, 25, 100, 500, 1000, 5000, 10000];
var getResult = function(indices, pot) {
var total = pot;
for (var i = 0; i < indices.length; i++) {
var index = indices[i];
var denom = denoms[index];
var chipCount = Math.floor(total / denom);
total -= chipCount * denom;
console.log(chipCount + "x $" + denom + " chips");
}
};
// test run
getResult([7,5], 17500);
// output
// 3x $5000 chips
// 5x $500 chips
I chose Javascript because you can just open the developer console on whatever browser you are running to read this and copy and paste the code in to test it. :)
Minimum chips is similar, because you just loop through each denomination, starting with the largest and do the same thing:
var getMinChips = function(pot) {
var total = pot;
// denoms assumed sorted in ascending order
for (var i = denoms.length - 1; i >= 0; i--) { // loop backwards through array
var denom = denoms[i];
var chipCount = Math.floor(total / denom);
if (chipCount > 0) {
total -= chipCount * denom;
console.log(chipCount + "x $" + denom + " chips");
}
}
};
// test
getMinChips(17500);
// output
// 1x $10000 chips
// 1x $5000 chips
// 2x $1000 chips
// 1x $500 chips
If you wanted to do something even more useful, you could also incorporate pot splits (where more than one player had the highest hand) by taking the denom and multiplying it by the number of players before dividing the pot by it. If you have a left-over chip after the lowest denomination, it's typically "thrown away" (by being left in the pot for the next hand).