solution to project euler, problem 12, in OCaml