Last active
August 29, 2015 14:02
-
-
Save mikekavouras/57515e3a39027ae4d957 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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