let count_divisors n = let c = ref 0 in let i = ref 1 in while !i * !i <= n do if n mod !i = 0 then begin c := !c + 1; if !i * !i <> n then c := !c + 1 end; i := !i + 1 done; !c let first_triangle_with_divs target = let t = ref 0 in let n = ref 0 in let found = ref false in while not !found do n := !n + 1; t := !t + !n; if count_divisors !t > target then found := true done; !t ;; first_triangle_with_divs 10