pow method

Fraction pow(
  1. int n
)

Returns the power of this fraction.

Implementation

Fraction pow(int n) {
  if (a == 0) {
    return this;
  }
  if (n > 0) {
    return Fraction(a.pow(n).toInt(), b.pow(n).toInt());
  } else if (n < 0) {
    return Fraction(b.pow(-n).toInt(), a.pow(-n).toInt());
  } else {
    return one;
  }
}