title: Rule to calculate power of a number when the exponent is Negative in Prolog?
body: <p>I have a power function <code>pow</code> that attempts to calculate the value of <code>B</code> to the power of  <code>E</code>. So far I handle the cases-<br>
  1. exponent is 0<br>
  2. exponent is non-zero  </p>
  
  <pre><code>pow(B,0,1).
  pow(B,E,Result):-   E2 is E - 1,
                      pow(B,E2,Result2),
                      Result is B*Result2.
  </code></pre>
  
  <p>How can I add another case where the power function can handle negative exponents?</p>