Created
December 19, 2020 15:27
-
-
Save vietnt/6a09f1751072fcf6656b4c56eef7be31 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec fib n = | |
match n with | |
| 0 -> 1 | |
| 1 -> 2 | |
| x -> fib (x - 1) + fib (x - 2) | |
Seq.initInfinite fib | |
|> Seq.takeWhile (fun n -> n <= 4_000_000) | |
|> Seq.filter (fun n -> n % 2 = 0) | |
|> Seq.sum | |
|> printfn "%A" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment