let payment principal annual_rate years =
  let r = annual_rate /. 12.0 in
  let n = years * 12 in
  let pow_r = ref 1.0 in
  for _ = 1 to n do pow_r := !pow_r *. (1.0 +. r) done;
  principal *. r *. !pow_r /. (!pow_r -. 1.0)

;;

int_of_float (payment 200000.0 0.05 30)
