title: factorial recursion and iteration in python
body: <p>please help me understand where i went wrong:</p>
  
  <p>this is the question:Create both a recursive function called recursive_factorial and iterative function called iterative_factorial that does the following</p>
  
  <pre><code>Accepts as parameter an Integer n
  Computes the factorial of n
  Returns the factorial of n
  </code></pre>
  
  <p>this is the test i am using for the question:</p>
  
  <pre><code>import unittest
  
  class RecursiveTestCase(unittest.TestCase):
  
    def test_recursive_factorial_one(self):
      result = recursive_factorial(4)
      self.assertEqual(result, 24, msg="Inaccurate value")
  
    def test_recursive_factorial_two(self):
      result = recursive_factorial(0)
      self.assertEqual(result, 1, msg="Inaccurate value")
  
    def test_iterative_factorial_one(self):
      result = iterative_factorial(5)
      self.assertEqual(result, 120, msg="Inaccurate value")
  
    def test_iterative_factorial_two(self):
      result = iterative_factorial(0)
      self.assertEqual(result, 1, msg="Inaccurate value")
  </code></pre>
  
  <p>this is the code i have written:</p>
  
  <pre><code>def recursive_factorial(n):
      if n == 0:
          return 1
      else:
          return n * recursive_factorial(n-1)
  def iterative_factorial(n):
      x = 1
      li = list(range(1, n + 1))
      for each in li:
          x = x * each
  </code></pre>
  
  <p>this is the error i am getting:</p>
  
  <p>1 .  test_iterative_factorial_one</p>
  
  <pre><code>Failure in line 21, in test_iterative_factorial_one self.assertEqual(result, 120, msg="Inaccurate value") AssertionError: Inaccurate value
  </code></pre>
  
  <p>2 .  test_iterative_factorial_two</p>
  
  <pre><code>Failure in line 25, in test_iterative_factorial_two self.assertEqual(result, 1, msg="Inaccurate value") AssertionError: Inaccurate value 
  </code></pre>
  
  <p>please help me understand where i went wrong.</p>