ocaml: phase 5.1 prime_factors.ml baseline (trial-division, 360 factor sum = 17)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 28s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 28s
Three refs threading through a while loop:
m remaining quotient
d current divisor
result accumulator (built in reverse, List.rev at end)
while !m > 1 do
if !m mod !d = 0 then begin
result := !d :: !result;
m := !m / !d
end else
d := !d + 1
done
360 = 2^3 * 3^2 * 5 factors to [2;2;2;3;3;5], sum 17.
60 baseline programs total — milestone.
This commit is contained in:
@@ -407,6 +407,12 @@ _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 — prime_factors.ml baseline (trial-division
|
||||
factorisation, sum of factors of 360 = 17). Three refs threading
|
||||
through a while loop: m holds the remaining quotient, d the
|
||||
current divisor, result accumulates factors. When `m mod d = 0`,
|
||||
push d and divide; otherwise increment d. 360 = 2^3 * 3^2 * 5
|
||||
factors to [2;2;2;3;3;5], sum 17. 60 baseline programs total.
|
||||
- 2026-05-09 Phase 5.1 — atm.ml baseline (mutable record + custom
|
||||
exception + try/with, balance 120 after rollback). Models a bank
|
||||
account: deposit/withdraw mutate the balance field; an over-draw
|
||||
|
||||
Reference in New Issue
Block a user