+ 1
Challenge:
Make a program using an array, that finds all numbers from 0 to 99999999 (all numbers until 8 digit numbers) that the the sum of their separate digits raised to the N power that the user provides gives the initial number. For ex. if N=4 the number 1634 is a correct answer, since 1^4+6^4+3^4+4^4=1634
2 Answers
+ 8
ES6:
for (var num = 1; num < Math.pow(10, 8); num++) {
var str = num.toString().split("");
if (str.reduce(function(a, b) { return a + Math.pow(b, str.length); }, 0) === num)
document.write(num + "<br>");
}
0
heres my
one liner#))
https://code.sololearn.com/cg7UgmFo94b8/?ref=app