Solution for problem 1 in Julia

This commit is contained in:
David Doblas Jiménez 2021-06-08 17:29:06 +02:00
parent 6d9d4526df
commit 7cf67f923f

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

@ -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())