trying out julia
parent
6d98dbb8b6
commit
1dc3b030e0
|
@ -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())
|
|
@ -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())
|
Loading…
Reference in New Issue