From 7cf67f923fcaebf012011c90b1087fd9369b54a0 Mon Sep 17 00:00:00 2001 From: daviddoji Date: Tue, 8 Jun 2021 17:29:06 +0200 Subject: [PATCH] Solution for problem 1 in Julia --- src/Julia/Problem001.jl | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/Julia/Problem001.jl diff --git a/src/Julia/Problem001.jl b/src/Julia/Problem001.jl new file mode 100644 index 0000000..19de345 --- /dev/null +++ b/src/Julia/Problem001.jl @@ -0,0 +1,27 @@ +#= +Created on 08 Jun 2021 + +@author: David Doblas Jiménez +@email: daviddoji@pm.me + +Solution for Problem 1 of Project Euler +https://projecteuler.net/problem=1 +=# + +function Problem1() + #= + If we list all the natural numbers below 10 that are multiples of 3 or 5, + we get 3, 5, 6 and 9. The sum of these multiples is 23. + + Find the sum of all the multiples of 3 or 5 below 1000. + =# + ans = sum(x for x in 0:999 if x%3==0 || x%5==0) + + return ans +end + + +println("Time to evaluate Problem 1:") +@time Problem1() +println("") +println("Result for Problem 1: ", Problem1()) \ No newline at end of file