let nth_prime n =
  let count = ref 0 in
  let i = ref 1 in
  let result = ref 0 in
  while !count < n do
    i := !i + 1;
    let p = ref true in
    let j = ref 2 in
    while !j * !j <= !i && !p do
      if !i mod !j = 0 then p := false;
      j := !j + 1
    done;
    if !p then begin
      count := !count + 1;
      if !count = n then result := !i
    end
  done;
  !result

;;

nth_prime 100
