# Project Euler Problem 2

Solution to Project Euler Problem 2 perfectly fits into the pattern **“select->filter->aggregate”**. The only twist is that instead of sequence of natural numbers our function **solve** should accept sequence of Fibonacci numbers.

let inline multipleOf divider number = number % divider = 0 let multipleOf2 = multipleOf 2 let fibnums = Seq.unfold (fun (current, next) -> Some(current, (next, current+next)))(0,1) fibnums |> solve ((>=) 4000000) multipleOf2 Seq.sum |> printfn "Problem 2 Answer: %d"

Worked like a charm! :grin:

Also solver aside, the solution would be

let inline multipleOf divider number = number % divider = 0 let multipleOf2 = multipleOf 2 let fibnums = Seq.unfold (fun (current, next) -> Some(current, (next, current+next)))(0,1) let problem002 () = fibnums |> Seq.takeWhile ((>=) 4000000) |> Seq.filter multipleOf2 |> Seq.sum

## Trackbacks & Pingbacks