// Strong numbers are the numbers that the sum of factorial of its digits
// is equal to the original number
// 145 is a strong number: 1 + 24 + 120 = 145
package main
import "fmt"
func factorial(n int) int {
fact := 1
for i := 2; i <= n; i++ {
fact *= i
}
return fact
}
func main() {
for n := 1; n <= 1000000; n++ {
tmp := n
sum := 0
for tmp != 0 {
reminder := tmp % 10
sum += factorial(reminder)
tmp /= 10
}
if sum == n {
fmt.Println(n)
}
}
}
/*
run:
1
2
145
40585
*/