input: Write a function to calculate the factorial of a number using a while loop.
  assert factorial(5) == 120
  assert factorial(0) == 1
  assert factorial(3) == 6
output: def factorial(n):
      result = 1
      while n > 0:
          result *= n
          n -= 1
      return result