ocaml: phase 5.1 euler1.ml baseline (Project Euler #1, multiples of 3 or 5 below 1000 = 233168)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 24s

Project Euler #1: sum of all multiples of 3 or 5 below 1000.

  let euler1 limit =
    let sum = ref 0 in
    for i = 1 to limit - 1 do
      if i mod 3 = 0 || i mod 5 = 0 then sum := !sum + i
    done;
    !sum

  euler1 1000 = 233168

Trivial DSL exercise but symbolically meaningful: this is the 100th
baseline program.

100 baseline programs total — milestone.
This commit is contained in:
2026-05-09 19:56:58 +00:00
parent 3759aad7a6
commit 53968c2480
3 changed files with 14 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
let euler1 limit =
let sum = ref 0 in
for i = 1 to limit - 1 do
if i mod 3 = 0 || i mod 5 = 0 then sum := !sum + i
done;
!sum
;;
euler1 1000

View File

@@ -24,6 +24,7 @@
"csv.ml": 10,
"exception_handle.ml": 4,
"exception_user.ml": 26,
"euler1.ml": 233168,
"expr_eval.ml": 16,
"expr_simp.ml": 22,
"factorial.ml": 3628800,

View File

@@ -407,6 +407,9 @@ _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 — euler1.ml baseline (Project Euler #1, sum
of multiples of 3 or 5 below 1000 = 233168). Trivial DSL exercise
but symbolically meaningful: this is the 100th baseline program.
- 2026-05-09 Phase 5.1 — anagram_groups.ml baseline (group strings
by canonical anagram form, ["eat";"tea";"tan";"ate";"nat";"bat"]
has 3 groups). canonical builds a sorted-by-frequency string