trying out julia

master
Evan Hemsley 2018-08-16 17:47:36 -07:00
parent 6d98dbb8b6
commit 1dc3b030e0
2 changed files with 30 additions and 0 deletions

9
julia/juler001.jl Normal file
View File

@ -0,0 +1,9 @@
function multiples_of_three_and_five_below(n)
filter(i -> (i % 3 == 0) || (i % 5 == 0), 3:(n-1))
end
function solution()
reduce(+, multiples_of_three_and_five_below(1000))
end
print(solution())

21
julia/juler002.jl Normal file
View File

@ -0,0 +1,21 @@
function even_fibonacci_up_to(n)
fibs = []
first = 1
second = 1
push!(fibs, first)
push!(fibs, second)
while second < n
temp = second
second = first + second
first = temp
push!(fibs, second)
end
pop!(fibs)
filter(i -> i % 2 == 0, fibs)
end
function solution()
reduce(+, even_fibonacci_up_to(4000000))
end
print(solution())