Skip to content

Instantly share code, notes, and snippets.

@mikekavouras
Last active August 29, 2015 14:02
Show Gist options
  • Save mikekavouras/57515e3a39027ae4d957 to your computer and use it in GitHub Desktop.
Save mikekavouras/57515e3a39027ae4d957 to your computer and use it in GitHub Desktop.
// Courtesy of Jeffery Rafter
function addToNine(num) {
var totals = [];
for (var i = 0; i < Math.pow(10, num); i++) {
var total = 0;
for (var j = 1; j <= num; j++) {
var max = Math.pow(10, j);
var min = max / 10;
total += (i % max - i % min) / min;
}
if (total === 9) {
totals.push(i);
}
}
return totals;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment