ocaml: phase 5.1 gcd_lcm.ml baseline (Euclidean gcd + lcm, 12+12+36 = 60)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 19s

Two-line baseline:

  let rec gcd a b = if b = 0 then a else gcd b (a mod b)
  let lcm a b = a * b / gcd a b

  gcd 36 48  = 12
  lcm 4 6    = 12
  lcm 12 18  = 36
  sum        = 60

Tests mod arithmetic and the integer-division fix from iteration 94
(without truncate-toward-zero, 'lcm 4 6 = 4 * 6 / 2 = 12.0' rather
than the expected 12).

54 baseline programs total.
This commit is contained in:
2026-05-09 11:42:52 +00:00
parent b8dfc080dd
commit cca3a28206
3 changed files with 13 additions and 0 deletions

View File

@@ -20,6 +20,7 @@
"factorial.ml": 3628800,
"fraction.ml": 7,
"frequency.ml": 5,
"gcd_lcm.ml": 60,
"grep_count.ml": 3,
"hanoi.ml": 1023,
"fizzbuzz.ml": 57,

View File

@@ -0,0 +1,6 @@
let rec gcd a b = if b = 0 then a else gcd b (a mod b)
let lcm a b = a * b / gcd a b
;;
gcd 36 48 + lcm 4 6 + lcm 12 18