diff --git a/lib/ocaml/baseline/abundant.ml b/lib/ocaml/baseline/abundant.ml new file mode 100644 index 00000000..c5b17781 --- /dev/null +++ b/lib/ocaml/baseline/abundant.ml @@ -0,0 +1,23 @@ +let div_sum n = + let s = ref 1 in + let i = ref 2 in + while !i * !i <= n do + if n mod !i = 0 then begin + s := !s + !i; + let q = n / !i in + if q <> !i then s := !s + q + end; + i := !i + 1 + done; + if n = 1 then 0 else !s + +let count_abundant n = + let c = ref 0 in + for i = 12 to n - 1 do + if div_sum i > i then c := !c + 1 + done; + !c + +;; + +count_abundant 100 diff --git a/lib/ocaml/baseline/expected.json b/lib/ocaml/baseline/expected.json index d995d935..88a56448 100644 --- a/lib/ocaml/baseline/expected.json +++ b/lib/ocaml/baseline/expected.json @@ -1,4 +1,5 @@ { + "abundant.ml": 21, "ackermann.ml": 125, "adler32.ml": 300286872, "anagram_check.ml": 2, diff --git a/plans/ocaml-on-sx.md b/plans/ocaml-on-sx.md index f779c07c..34acfbec 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 — abundant.ml baseline (count abundant numbers + < 100 = 21). Abundant means d(n) > n where d(n) is the proper- + divisor sum. Reuses the trial-division div_sum helper from iter + 205. 21 abundant numbers under 100, starting at 12, 18, 20, 24... + 124 baseline programs total. - 2026-05-10 Phase 5.1 — euler36.ml baseline (sum of double-base palindromes ≤ 1000 = 1772). Numbers that read the same in base 10 and base 2: 1, 3, 5, 7, 9, 33, 99, 313, 585, 717. Sum = 1772.