input: Write a function that calculates the greatest common divisor (GCD) of two given numbers and returns the result. If either of the numbers is zero, the function should return the non-zero number as the GCD. The function should be named `gcd` and take two arguments `a` and `b`.
  assert gcd(10, 20)==10
  assert gcd(8, 12)==4
  assert gcd(0, 5)==5
  assert gcd(7, 0)==7
  assert gcd(0, 0)==0
output: def gcd(a, b):
      while b != 0:
          a, b = b, a % b
      return a