title: Python - Recursive way to return a list of the divisors of an integer
body: <p>I was trying to write a function that would return the list of a divisors of some positive integer </p>
  
  <p>divisors(12) => [1,2,3,4,6,12]</p>
  
  <p>I did it with a for loop, and then tried to do it with a recursion, but I couldn't figure out how to do it and found no example of it online in any language.</p>
  
  <pre><code>def divisors(n,l=[]):
      b=1
      if n &lt; 1:
          return l
      if n == 1:
  </code></pre>
  
  <p>I thought using l=[] would work better than yield, but in any way, I couldn't get anywhere with it.</p>
  
  <p><strong>Edit:</strong>
  using @vks code I wrote the following:</p>
  
  <pre><code>def fun(n, l=[],divisor=1):
      if n % divisor == 0:
          l.append(divisor)
      if divisor == n:
          return None
      fun(n, l, divisor+1)
      return l
  </code></pre>