Factoring
Implement the function
val factor : int -> (int * int) list
so that factor n computes the prime factorization of n and returns
it as a list of pairs of a prime factor and its corresponding
exponent. That is, if n can be written as \(p_1^{e_1} \cdot
p_2^{e_2} \cdots p_k^{e_k}\), then factor n should be [(p1, e1);
(p2, e2); ...; (pk, ek)], with the primes appearing in increasing
order. The behavior of the function is undefined if the input is not
positive.
Examples
let _ = assert (factor 1 = []) let _ = assert (factor 19 = [(19,1)]) let _ = assert (factor 16 = [(2,4)]) let _ = assert (factor 360 = [(2,3);(3,2);(5,1)])