Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 25s
Sieve of Eratosthenes followed by a sum loop:
let sieve_sum n =
let s = Array.make (n + 1) true in
s.(0) <- false;
s.(1) <- false;
for i = 2 to n do
if s.(i) then begin
let j = ref (i * i) in
while !j <= n do
s.(!j) <- false;
j := !j + i
done
end
done;
let total = ref 0 in
for i = 2 to n do
if s.(i) then total := !total + i
done;
!total
Real PE10 asks for sum below 2,000,000; that's a ~2-3 second loop in
native OCaml but minutes-to-hours under our contended-host
spec-level evaluator. 100 keeps the run under 3 minutes while still
exercising the same algorithm.
110 baseline programs total.
23 lines
376 B
OCaml
23 lines
376 B
OCaml
let sieve_sum n =
|
|
let s = Array.make (n + 1) true in
|
|
s.(0) <- false;
|
|
s.(1) <- false;
|
|
for i = 2 to n do
|
|
if s.(i) then begin
|
|
let j = ref (i * i) in
|
|
while !j <= n do
|
|
s.(!j) <- false;
|
|
j := !j + i
|
|
done
|
|
end
|
|
done;
|
|
let total = ref 0 in
|
|
for i = 2 to n do
|
|
if s.(i) then total := !total + i
|
|
done;
|
|
!total
|
|
|
|
;;
|
|
|
|
sieve_sum 100
|