normalize method

Rat normalize()

Returns a new Rat with the smallest denominator for the fraction.

Implementation

Rat normalize() {
  final gcd = n.gcd(d);
  return Rat(n ~/ gcd, d ~/ gcd);
}