Last active
August 29, 2015 14:11
-
-
Save off-by-some/f6d9d932697e8061136b to your computer and use it in GitHub Desktop.
euler
This file contains hidden or 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
| module main | |
| let print sol = | |
| printfn "%i" sol | |
| let solve problem = | |
| problem |> print | |
| let fibonacci = | |
| Seq.unfold | |
| (fun (current, next) -> Some(current, (next, current + next))) | |
| (0, 1) | |
| let problem1 = | |
| [1..999] | |
| |> List.filter (fun x -> (x % 3) = 0 || (x % 5) = 0) | |
| |> List.sum | |
| //sum of even fibonacci numbers up to 4 million | |
| let problem2 = | |
| fibonacci | |
| |> Seq.takeWhile (fun x -> x < 4000000) | |
| |> Seq.filter (fun x -> (x % 2) = 0) | |
| |> Seq.sum | |
| solve problem1 | |
| solve problem2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment