title: Writing a function to find a triangular number in python 2.7
body: <p>I couldn't find an answer by searching and I've been working on this for two days and am stumped. I think I am just confused on the math. I am trying to write a function that finds the first n triangular numbers. </p>
  
  <pre><code>def formula(n):
      i = 1
      while i &lt;= n:
          print i, '\t', n * (n + 1)/ 2
          i += 1
      print
  </code></pre>
  
  <p>So for example if I type in formula(5) it would look like this:</p>
  
  <pre><code> 1       1
   2       3
   3       6
   4       10
   5       15
  </code></pre>
  
  <p>I got how to make a table going from 1 through whatever number I choose n.. but I can't figure out how to make the second part equal the formula I typed in which would be n*(n+1)/2. What is the logic going through this? Everytime I type in formula(5) for example the loop goes from 1-5 but returns the same exact answer in the right hand column all the way down which would be 15. I can't make it to where it would start at 1, 3, 6 etc on the right hand side. </p>