共用方式為


Project Euler Problem #2

Sum of even terms in Fibonacci sequence which are < four-million:

 

(1, 1) |> Seq.unfold (fun (a, b) -> Some(a, (b, a + b))) // fibs

|> Seq.takeWhile (fun x -> x <= 4000000)

|> Seq.filter (fun x -> x % 2 = 0)

|> Seq.sum

 

I like how Fibonacci can be represented as a single unfold.