1 min read

APL Hacking: Project Euler Daily (#2)

For this one, I could not come up with a solution that did not have a loop in it, but I tried to make that loop as simple as possible.

Problem #2:

∇R←PETWO;X;⎕IO
⎕IO←1

⍝ Find the sum of all even fibonacci numbers < 4,000,000
X←0 1
:Repeat
X←X,X[⍴X]+X[(⍴X)-1]
:Until X[⍴X]>4000000
R←+/(0=2|X)/X