lundi 1 mars 2010

Project Euler #1

let rec range n m = if n > m then [] else n :: range (n + 1) m;;
Printf.printf "%d\n" 
  (List.fold_left (+) 0 (List.map 
     (fun n -> if n mod 3 == 0 or n mod 5 == 0 then n else 0) 
        (range 1 999)))

Aucun commentaire:

Publier un commentaire