Files
rose-ash/lib/ocaml
giles 89a807a1ed
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s
ocaml: phase 5.1 euler14.ml baseline (longest Collatz under 100, starting n = 97)
collatz_len walks n through n/2 if even, 3n+1 if odd, counting
steps. Outer loop scans 2..N tracking the best length and arg-best:

  let euler14 limit =
    let best = ref 0 in
    let best_n = ref 0 in
    for n = 2 to limit do
      let l = collatz_len n in
      if l > !best then begin
        best := l;
        best_n := n
      end
    done;
    !best_n

  euler14 100 = 97   (97 generates a 118-step chain)

Real PE14 uses limit = 1_000_000 (answer 837799); 100 exercises the
same algorithm in <2 minutes on our contended host.

116 baseline programs total.
2026-05-09 22:53:27 +00:00
..