title: How can I implement a summatory with a cycle and recurssion
body: <p>If i had this function</p>
  
  <pre><code>def P(n):
      iterador = 0
      while ( iterador &lt;= n ):
          print(iterador)
          iterador = iterador + 1
  P(8)
  </code></pre>
  
  <p>Which prints </p>
  
  <pre><code>1
  2
  3
  4
  5
  6
  7
  8
  </code></pre>
  
  <p>What would I have to do, in order to add each number, like this</p>
  
  <pre><code>1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 = 36
  </code></pre>
  
  <p>I know it would be something like:</p>
  
  <pre><code>P(n) = 1 + 2 + 3 +...+ n
  
  P(1) = 1
  P(2) = P(1) + 2
  P(3) = P(2) + 3
  .
  .
  .
  </code></pre>
  
  <p><strong>P(n) = P(n-1) + n</strong></p>
  
  <p>But I don't know how to put it into code.</p>
  
  <p>Could someone give me a hand.</p>
  
  <p>Thanks.</p>