input: Write a function to print a pattern of stars based on the number of rows.
  assert pattern(3) == "* \n* * \n* * * \n"
  assert pattern(4) == "* \n* * \n* * * \n* * * * \n"
  assert pattern(5) == "* \n* * \n* * * \n* * * * \n* * * * * \n"
output: def pattern(n):
      result = ""
      for i in range(1, n + 1):
          result += "* " * i + "\n"
      return result