ocaml: phase 5.1 euler10.ml baseline (sum of primes <= 100 = 1060, scaled-down PE10)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 25s

Sieve of Eratosthenes followed by a sum loop:

  let sieve_sum n =
    let s = Array.make (n + 1) true in
    s.(0) <- false;
    s.(1) <- false;
    for i = 2 to n do
      if s.(i) then begin
        let j = ref (i * i) in
        while !j <= n do
          s.(!j) <- false;
          j := !j + i
        done
      end
    done;
    let total = ref 0 in
    for i = 2 to n do
      if s.(i) then total := !total + i
    done;
    !total

Real PE10 asks for sum below 2,000,000; that's a ~2-3 second loop in
native OCaml but minutes-to-hours under our contended-host
spec-level evaluator. 100 keeps the run under 3 minutes while still
exercising the same algorithm.

110 baseline programs total.
This commit is contained in:
2026-05-09 21:46:16 +00:00
parent 00ffba9306
commit 853504642f
3 changed files with 27 additions and 0 deletions

View File

@@ -407,6 +407,10 @@ _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 — euler10.ml baseline (sum of primes ≤ 100 =
1060, scaled-down Project Euler #10). Sieve of Eratosthenes
followed by a sum loop. Used 100 instead of 2 million to fit our
contended host's runtime budget. 110 baseline programs total.
- 2026-05-09 Phase 5.1 — euler5.ml baseline (Project Euler #5,
smallest number divisible by all 1..20 = 232792560). Iteratively
takes lcm of running result with i for i=2..n; lcm via gcd via