Solution to problem 20 in Julia

This commit is contained in:
David Doblas Jiménez 2021-08-03 11:29:06 +02:00
parent a7572ae035
commit 7de498efb6

27
src/Julia/Problem020.jl Normal file
View File

@ -0,0 +1,27 @@
#=
Created on 03 Aug 2021
@author: David Doblas Jiménez
@email: daviddoji@pm.me
Solution for Problem 20 of Project Euler
https://projecteuler.net/problem=20 =#
function Problem20()
#=
n! means n × (n 1) × ... × 3 × 2 × 1
For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
and the sum of the digits in the number 10! is:
3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100! =#
fact = factorial(big(100))
return sum(parse(Int, d) for d in string(fact))
end
println("Time to evaluate Problem 20:")
@time Problem20()
println("")
println("Result for Problem 20: ", Problem20())