From 7f6ea29f1a17fbdc9a06dfb88ae42baa03730d95 Mon Sep 17 00:00:00 2001 From: daviddoji Date: Mon, 26 Jul 2021 19:15:20 +0200 Subject: [PATCH] Solution to problem 16 in Julia --- src/Julia/Problem016.jl | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/Julia/Problem016.jl diff --git a/src/Julia/Problem016.jl b/src/Julia/Problem016.jl new file mode 100644 index 0000000..670ae1f --- /dev/null +++ b/src/Julia/Problem016.jl @@ -0,0 +1,26 @@ +using Base: Integer +#= +Created on 26 Jul 2021 + +@author: David Doblas Jiménez +@email: daviddoji@pm.me + +Solution for Problem 16 of Project Euler +https://projecteuler.net/problem=16 +=# + +function Problem16() + #= + 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. + + What is the sum of the digits of the number 2^1000? + =# + n = 1000 + return sum(parse(Int, d) for d in string(2^BigInt(n))) +end + + +println("Time to evaluate Problem 16:") +@time Problem16() +println("") +println("Result for Problem 16: ", Problem16())