Use benchmark macro
This commit is contained in:
@@ -5,7 +5,8 @@ Created on 08 Jun 2021
|
|||||||
@email: daviddoji@pm.me
|
@email: daviddoji@pm.me
|
||||||
|
|
||||||
Solution for Problem 2 of Project Euler
|
Solution for Problem 2 of Project Euler
|
||||||
https://projecteuler.net/problem=2 =#
|
https://projecteuler.net/problem=2
|
||||||
|
=#
|
||||||
|
|
||||||
using BenchmarkTools
|
using BenchmarkTools
|
||||||
|
|
||||||
@@ -17,12 +18,14 @@ function Problem2()
|
|||||||
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
|
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
|
||||||
|
|
||||||
Find the sum of all the even-valued terms in the sequence which do not
|
Find the sum of all the even-valued terms in the sequence which do not
|
||||||
exceed four million. =#
|
exceed four million.
|
||||||
|
=#
|
||||||
|
|
||||||
ans = 0
|
ans = 0
|
||||||
limit = 4_000_000
|
limit = 4_000_000
|
||||||
x, y = 1, 1
|
x, y = 1, 1
|
||||||
z = x + y # Because every third Fibonacci number is even
|
# Because every third Fibonacci number is even
|
||||||
|
z = x + y
|
||||||
while z <= limit
|
while z <= limit
|
||||||
ans += z
|
ans += z
|
||||||
x = y + z
|
x = y + z
|
||||||
|
|||||||
Reference in New Issue
Block a user