let euler29 n =
  let h = Hashtbl.create 64 in
  for a = 2 to n do
    for b = 2 to n do
      let p = ref 1 in
      for _ = 1 to b do p := !p * a done;
      Hashtbl.replace h !p ()
    done
  done;
  Hashtbl.length h

;;

euler29 5
