Files
rose-ash/plans
giles 36e02c906a
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 29s
ocaml: phase 5.1 pythagorean.ml baseline (primitive Pythagorean triples with hyp <= 100 = 16)
Uses Euclid's formula: for coprime m > k of opposite parity, the
triple (m^2 - k^2, 2mk, m^2 + k^2) is a primitive Pythagorean.

  let count_primitive_triples n =
    let c = ref 0 in
    for m = 2 to 50 do
      let kk = ref 1 in
      while !kk < m do
        if (m - !kk) mod 2 = 1 && gcd m !kk = 1 then begin
          let h = m * m + !kk * !kk in
          if h <= n then c := !c + 1
        end;
        kk := !kk + 1
      done
    done;
    !c

  count_primitive_triples 100 = 16

The 16 triples include the classics (3,4,5), (5,12,13), (8,15,17),
(7,24,25), and end with (65,72,97).

134 baseline programs total.
2026-05-10 03:02:17 +00:00
..