let rec expt a n = if Q.equal a zero then zero else if n < 0 then Q.inv (expt a (-n)) else if n = 0 then one else if n = 1 then a else mult a (expt a (n - 1))