input: 
  def tri(n):
      """The Fibonacci sequence is widely recognized, having been extensively explored by mathematicians over the past few centuries. In contrast, the Tribonacci sequence is less known. Its definition relies on the following pattern:
      tri(1) = 3
      For even n: tri(n) = 1 + n / 2
      For odd n: tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1)
      As an illustration:
      tri(2) = 1 + (2 / 2) = 2
      tri(4) = 3
      tri(3) = tri(2) + tri(1) + tri(4)
             = 2 + 3 + 3 = 8 
      Given a non-negative integer n, your task is to return a list containing the first n + 1 numbers of the Tribonacci sequence.
      For instance:
      tri(3) = [1, 3, 2, 8]
      """
  
output:     
      if n == 0:
          return [3]
      if n == 1:
          return [3, 2]
      if n == 2:
          return [3, 2, 3]
      
      trib_seq = [3, 2, 3]
      
      for i in range(3, n + 1):
          if i % 2 == 0:
              next_value = 1 + i / 2
          else:
              next_value = trib_seq[i - 1] + trib_seq[i - 2] + trib_seq[i - 3]
          
          trib_seq.append(next_value)
      
      return trib_seq
  