Project Euler‎ > ‎

Problem 2 in F#

posted Aug 27, 2009, 6:35 AM by Peter Henell
let problem2 = 
let rec fib n
=
match n
with
|
0 -> 0
|
1 | 2 -> 1
| n
-> (fib (n - 1)) + (fib (n - 2))

{
1..35} |> Seq.map (fun x -> fib x)
|
> Seq.filter ( fun z -> (z < 1000000 && z % 2 = 0))
|
> Seq.sumByInt(fun y -> y)
Comments