let pi_approx n =
  let total = ref 0.0 in
  for k = 0 to n - 1 do
    let sign = if k mod 2 = 0 then 1.0 else -1.0 in
    total := !total +. sign /. float_of_int (2 * k + 1)
  done;
  4.0 *. !total
;;

int_of_float (pi_approx 1000 *. 100.0)
