input: Write a python function to perform arithmetic operations on rational numbers.
  assert str(Rational(1, 2).add(Rational(1, 3))) == "5/6"
  assert str(Rational(1, 2).subtract(Rational(1, 3))) == "1/6"
  assert str(Rational(1, 2).multiply(Rational(1, 3))) == "1/6"
  assert str(Rational(1, 2).divide(Rational(1, 3))) == "3/2"
output: def gcd(a, b):
      while b:
          a, b = b, a % b
      return a
  
  class Rational:
      def __init__(self, numerator, denominator):
          if denominator == 0:
              raise ValueError("Denominator cannot be zero.")
          common_divisor = gcd(numerator, denominator)
          self.numerator = numerator // common_divisor
          self.denominator = denominator // common_divisor
      
      def add(self, other):
          new_numerator = self.numerator * other.denominator + other.numerator * self.denominator
          new_denominator = self.denominator * other.denominator
          return Rational(new_numerator, new_denominator)
      
      def subtract(self, other):
          new_numerator = self.numerator * other.denominator - other.numerator * self.denominator
          new_denominator = self.denominator * other.denominator
          return Rational(new_numerator, new_denominator)
      
      def multiply(self, other):
          new_numerator = self.numerator * other.numerator
          new_denominator = self.denominator * other.denominator
          return Rational(new_numerator, new_denominator)
      
      def divide(self, other):
          new_numerator = self.numerator * other.denominator
          new_denominator = self.denominator * other.numerator
          if new_denominator == 0:
              raise ValueError("Cannot divide by zero.")
          return Rational(new_numerator, new_denominator)
      
      def __str__(self):
          return f"{self.numerator}/{self.denominator}"