Skip to content

Instantly share code, notes, and snippets.

@zestime
Created July 21, 2016 00:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save zestime/464c8d46290a03a6f6b5a486a1f1a1e1 to your computer and use it in GitHub Desktop.
Save zestime/464c8d46290a03a6f6b5a486a1f1a1e1 to your computer and use it in GitHub Desktop.
JavaScript ver. of Counting coins
function countChange(money, coins) {
if (money == 0) return 1;
if (money < 0 || coins.length == 0) return 0;
return countChange(money - coins[0], coins) + countChange(money, coins.slice(1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment