From 7de498efb6b35cc6684ba20b9ce8d5d006710a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Doblas=20Jim=C3=A9nez?= Date: Tue, 3 Aug 2021 11:29:06 +0200 Subject: [PATCH] Solution to problem 20 in Julia --- src/Julia/Problem020.jl | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/Julia/Problem020.jl diff --git a/src/Julia/Problem020.jl b/src/Julia/Problem020.jl new file mode 100644 index 0000000..9dbd59e --- /dev/null +++ b/src/Julia/Problem020.jl @@ -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()) \ No newline at end of file