Sum multiples of 3 and 5: Difference between revisions
→Functional programming version (more idiomatic)
Line 2,895:
open Printf;;
let
let rec
Seq.scan (+) 0 (List.to_seq wheel);;
let sum3or5 upto =
printf "The sum of the multiples of 3 or 5 below 1000 is %d\n" (sum_mults 999);;▼
mul3or5 |> Seq.take_while (fun n -> n < upto) |> Seq.fold_left (+) 0;;
</lang>
{{Out}}
|