// Strong numbers are the numbers that the sum of the factorial of its digits
// is equal to the original number
// 145 is a strong number: 1 + 24 + 120 = 145
for (let n = 1; n <= 1000000; n++) {
let tmp = n;
let sum = 0;
let reminder = 0;
while (tmp != 0) {
reminder = tmp % 10;
sum = sum + factorial(reminder);
tmp = Math.floor(tmp / 10);
}
if (sum == n) {
console.log(n);
}
}
function factorial(n) {
let fact = 1;
for (let i = 2; i <= n; i++) {
fact = fact * i;
}
return fact;
}
/*
run:
1
2
145
40585
*/