Solution for problem 1 in Julia
This commit is contained in:
parent
6d9d4526df
commit
7cf67f923f
27
src/Julia/Problem001.jl
Normal file
27
src/Julia/Problem001.jl
Normal 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())
|
Loading…
x
Reference in New Issue
Block a user