diff --git a/lib/ocaml/baseline/euler1.ml b/lib/ocaml/baseline/euler1.ml new file mode 100644 index 00000000..42cb2d01 --- /dev/null +++ b/lib/ocaml/baseline/euler1.ml @@ -0,0 +1,10 @@ +let euler1 limit = + let sum = ref 0 in + for i = 1 to limit - 1 do + if i mod 3 = 0 || i mod 5 = 0 then sum := !sum + i + done; + !sum + +;; + +euler1 1000 diff --git a/lib/ocaml/baseline/expected.json b/lib/ocaml/baseline/expected.json index bc8170b1..dd452b56 100644 --- a/lib/ocaml/baseline/expected.json +++ b/lib/ocaml/baseline/expected.json @@ -24,6 +24,7 @@ "csv.ml": 10, "exception_handle.ml": 4, "exception_user.ml": 26, + "euler1.ml": 233168, "expr_eval.ml": 16, "expr_simp.ml": 22, "factorial.ml": 3628800, diff --git a/plans/ocaml-on-sx.md b/plans/ocaml-on-sx.md index 3c78bdef..66b49f0d 100644 --- a/plans/ocaml-on-sx.md +++ b/plans/ocaml-on-sx.md @@ -407,6 +407,9 @@ _Newest first._ binary search tree (`type 'a tree = Leaf | Node of 'a * 'a tree * 'a tree`) with insert + in-order traversal. Tests parametric ADT, recursive match, List.append, List.fold_left. +- 2026-05-09 Phase 5.1 — euler1.ml baseline (Project Euler #1, sum + of multiples of 3 or 5 below 1000 = 233168). Trivial DSL exercise + but symbolically meaningful: this is the 100th baseline program. - 2026-05-09 Phase 5.1 — anagram_groups.ml baseline (group strings by canonical anagram form, ["eat";"tea";"tan";"ate";"nat";"bat"] has 3 groups). canonical builds a sorted-by-frequency string