$145$ is a curious number, as $1! + 4! + 5! = 1 + 24 + 120 = 145$.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: as $1! = 1$ and $2! = 2$ are not sums they are not included.
In [1]:
for i=0:9
println(i, " ",factorial(i))
end
In [7]:
addprocs(7)
function brute(m)
@parallel for i=10:m
s = 0
n = i
while i != 0
s += factorial(mod(i, 10))
i = div(i, 10)
end
if s == n
println("x -> ", s)
end
end
end
@time brute(9999999)
Out[7]:
In [ ]:
vcat([1, 2], [3, 4])
In [8]:
145+40585
Out[8]:
In [ ]: