diff --git a/lib/ocaml/baseline/expected.json b/lib/ocaml/baseline/expected.json index 07296ad2..f2b22765 100644 --- a/lib/ocaml/baseline/expected.json +++ b/lib/ocaml/baseline/expected.json @@ -122,6 +122,7 @@ "sum_squares.ml": 385, "tree_depth.ml": 4, "triangle.ml": 11, + "triangle_div.ml": 120, "twosum.ml": 5, "unique_set.ml": 9, "validate.ml": 417, diff --git a/lib/ocaml/baseline/triangle_div.ml b/lib/ocaml/baseline/triangle_div.ml new file mode 100644 index 00000000..20c079db --- /dev/null +++ b/lib/ocaml/baseline/triangle_div.ml @@ -0,0 +1,26 @@ +let count_divisors n = + let c = ref 0 in + let i = ref 1 in + while !i * !i <= n do + if n mod !i = 0 then begin + c := !c + 1; + if !i * !i <> n then c := !c + 1 + end; + i := !i + 1 + done; + !c + +let first_triangle_with_divs target = + let t = ref 0 in + let n = ref 0 in + let found = ref false in + while not !found do + n := !n + 1; + t := !t + !n; + if count_divisors !t > target then found := true + done; + !t + +;; + +first_triangle_with_divs 10 diff --git a/plans/ocaml-on-sx.md b/plans/ocaml-on-sx.md index 4de83aaf..312d14ae 100644 --- a/plans/ocaml-on-sx.md +++ b/plans/ocaml-on-sx.md @@ -407,6 +407,11 @@ _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-10 Phase 5.1 — triangle_div.ml baseline (first triangle + number with > 10 divisors = 120). PE12 with target 10. T(15) = 120 + has 16 divisors {1,2,3,4,5,6,8,10,12,15,20,24,30,40,60,120} — + first to break 10. Real PE12 uses target 500 (answer 76576500); + 10 stays well under our budget. 126 baseline programs total. - 2026-05-10 Phase 5.1 — perfect.ml baseline (count perfect numbers ≤ 500 = 3). Perfect numbers = those where d(n) = n. Three under 500: 6, 28, 496. (8128 is the next.) Same div_sum machinery as