let is_prime n =
  if n < 2 then false
  else
    let p = ref true in
    let i = ref 2 in
    while !i * !i <= n && !p do
      if n mod !i = 0 then p := false;
      i := !i + 1
    done;
    !p

let count_primes n =
  let c = ref 0 in
  for i = 2 to n do
    if is_prime i then c := !c + 1
  done;
  !c

;;

count_primes 100
