Euler Problem 002 with F#
Problem Statement
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
Solutions
Recursive Solution:
[gist]4219743[/gist]
Using infinite Fibonacci sequence:
[gist]4219827[/gist]
A bit shorter version can be derived using Seq.SumBy:
[gist]4219837[/gist]
Result
> val eulerProblem2Answer : int = 4613732 val eulerProblem2Answer' : int = 4613732 val eulerProblem2Answer'' : int = 4613732
Comments ()