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
