Skip to content

Instantly share code, notes, and snippets.

@codejockie
Forked from zestime/countChange.js
Created February 23, 2019 23:56
Show Gist options
  • Save codejockie/063729459e28950a1370592b86930292 to your computer and use it in GitHub Desktop.
Save codejockie/063729459e28950a1370592b86930292 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