Skip to content

Instantly share code, notes, and snippets.

@off-by-some
Last active August 29, 2015 14:11
Show Gist options
  • Select an option

  • Save off-by-some/f6d9d932697e8061136b to your computer and use it in GitHub Desktop.

Select an option

Save off-by-some/f6d9d932697e8061136b to your computer and use it in GitHub Desktop.
euler
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