ocaml: phase 5.1 euler5.ml baseline (smallest multiple of 1..20 = 232792560)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 29s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 29s
Iteratively takes lcm of running result with i:
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
let euler5 n =
let r = ref 1 in
for i = 2 to n do
r := lcm !r i
done;
!r
euler5 20 = 232792560
= 2^4 * 3^2 * 5 * 7 * 11 * 13 * 17 * 19
Tests gcd_lcm composition (iter 140) on a fresh problem.
109 baseline programs total.
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
"exception_user.ml": 26,
|
||||
"euler1.ml": 233168,
|
||||
"euler2.ml": 4613732,
|
||||
"euler5.ml": 232792560,
|
||||
"euler6.ml": 25164150,
|
||||
"euler9.ml": 31875000,
|
||||
"expr_eval.ml": 16,
|
||||
|
||||
Reference in New Issue
Block a user