ocaml: phase 5.1 euler29_small.ml baseline (distinct a^b for 2<=a,b<=5 = 15)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 40s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 40s
Compute every power a^b for a, b in [2..N] and count distinct
values. Hashtbl as a set with unit-payload (iter-168 idiom):
let euler29 n =
let h = Hashtbl.create 64 in
for a = 2 to n do
for b = 2 to n do
let p = ref 1 in
for _ = 1 to b do p := !p * a done;
Hashtbl.replace h !p ()
done
done;
Hashtbl.length h
For N=5: 16 powers minus one duplicate (4^2 = 2^4 = 16) -> 15.
Real PE29 uses N=100 (answer 9183).
120 baseline programs total — milestone.
This commit is contained in:
@@ -407,6 +407,11 @@ _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 — euler29_small.ml baseline (distinct a^b for
|
||||
2≤a,b≤5 = 15). 16 powers minus the one duplicate (4^2 = 2^4 = 16)
|
||||
→ 15 distinct values. Hashtbl as a set with unit-payload (the
|
||||
iter-168 idiom). Real PE29 uses N=100 (answer 9183). 120 baseline
|
||||
programs total — milestone.
|
||||
- 2026-05-09 Phase 5.1 — euler21_small.ml baseline (sum of amicable
|
||||
numbers ≤ 300 = 504). div_sum computes proper divisor sum via
|
||||
trial division up to √n; outer loop finds amicable pairs (a, b)
|
||||
|
||||
Reference in New Issue
Block a user