def gcd(num_a, num_b):
    """Calculates the greatest common divisor.

  Non-recursive fast implementation.

  :param num_a:
      Long value.
  :param num_b:
      Long value.
  :returns:
      Greatest common divisor.
  """
    num_a, num_b = max(num_a, num_b), min(num_a, num_b)
    while num_b:
        num_a, num_b = num_b, num_a % num_b
    return num_a
