input: Below is an instruction that describes a task. Write a response that appropriately completes the request.
  
  ### Instruction:
  Create an algorithm in Python to generate the first n elements of the Sierpinski triangle.
  
  ### Input:
  n = 6
  
  ### Output:
  def sierpinski_triangle(n): 
      """
      Generates the first n elements of the Sierpinski triangle.
      >>> sierpinski_triangle(6)
       1  
       0  
      1 1 1  
      0 0 0  
     1 1 1 1 1  
     0 0 0 0 0  
      """
      for i in range(2**n): 
          print(' ', end=" ") 
      
      for i in range(1, n+1): 
          for j in range(2**(i-1), 2**i): 
              print('1', end=" ") 
          print() 
          
          if i > 1: 
              for j in range(2**(i-1)+1, 2**i-1):  
                  print('0', end=" ") 
              print() 
         
  sierpinski_triangle(6)
output:     
      result = []
      for i in range(n):
          row = []
          for j in range(i + 1):
              if j == 0 or j == i:
                  row.append(1)
              else:
                  row.append(result[i - 1][j - 1] + result[i - 1][j])
          result.append(row)
      
      for row in result:
          for num in row:
              if num % 2 == 0:
                  print('0', end=" ")
              else:
                  print('1', end=" ")
          print()
  