diff --git a/src/Julia/Problem040.jl b/src/Julia/Problem040.jl new file mode 100644 index 0000000..b5c0e4a --- /dev/null +++ b/src/Julia/Problem040.jl @@ -0,0 +1,40 @@ +#= +Created on 10 Sep 2021 + +@author: David Doblas Jiménez +@email: daviddoji@pm.me + +Solution for Problem 40 of Project Euler +https://projecteuler.net/problem=40 +=# + +using BenchmarkTools + +function Problem40() + #= + An irrational decimal fraction is created by concatenating the positive integers: + + 0.123456789101112131415161718192021... + + It can be seen that the 12th digit of the fractional part is 1. + + If d_n represents the n^th digit of the fractional part, find the value of the following expression. + + d_1 × d_{10} × d_{100} × d_{1_000} × d_{10_000} × d_{100_000} × d_{1_000_000} + + =# + ans = 1 + fraction = join([i for i in 1:1_000_000]) + + for i in 0:6 + ans *= parse(Int, fraction[10^i]) + end + + return ans +end + + +println("Time to evaluate Problem 40:") +@btime Problem40() +println("") +println("Result for Problem 40: ", Problem40())