Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

15 lines (11 sloc) 0.388 kb
open Printf
let sum a b =
a + b
;;
let rec fib l limit =
match List.length l with
| 0 -> fib (1 :: l) limit
| 1 -> fib (2 :: l) limit
| _ -> if ((List.nth l 0) + (List.nth l 1)) > limit then l else fib (((List.nth l 0) + (List.nth l 1)) :: l) limit
;;
printf "%d\n" (List.fold_left sum 0 (List.filter (fun n -> n mod 2 == 0) (fib [] 4000000)))
Jump to Line
Something went wrong with that request. Please try again.