title: Convert the following into a recursive function
body: <p>How should i convert the following into a recursive function so that the output will also be [1, 2, 6, 24, 120]?</p>
  
  <pre><code>def factorial(n):
      l = []
      value = 1
      for x in range(1, n+1):
          value = value * x
          l.append(value)
      print(l)
  
  
  factorial(5)
  </code></pre>
  
  <p>The following is my recursion code. I am not sure on how i should use append in the function to create the list, any suggestions?</p>
  
  <pre><code>def factorial(n):
      if n == 1:
          L.append(1)
          return 1
      else:
          return n * factorial(n-1)
  
  
  x = int(input("Enter value of n: "))
  L = []
  
  print(factorial(x))
  print(L)
  </code></pre>