Solution for problem 2 in Julia

This commit is contained in:
David Doblas Jiménez 2021-06-15 19:36:30 +02:00
parent b7392266cf
commit e45bcfdc4d

34
src/Julia/Problem002.jl Normal file
View File

@ -0,0 +1,34 @@
#=
Created on 08 Jun 2021
@author: David Doblas Jiménez
@email: daviddoji@pm.me
Solution for Problem 2 of Project Euler
https://projecteuler.net/problem=2
=#
function Problem2()
#=
Statement
=#
ans = 0
limit = 4_000_000
x, y = 1, 1
z = x + y # Because every third Fibonacci number is even
while z <= limit
ans += z
x = y + z
y = z + x
z = x + y
end
return ans
end
println("Time to evaluate Problem 2:")
@time Problem2()
println("")
println("Result for Problem 2: ", Problem2())