title: Writing recursive functions
body: <p>I'm having trouble with writing recursive functions.</p>
  
  <p>The triangular numbers are as follows:</p>
  
  <p>1 = 1</p>
  
  <p>3 = 1 + 2 </p>
  
  <p>6 = 1 + 2 + 3 </p>
  
  <p>10 = 1 + 2 + 3 + 4</p>
  
  <p>15 = 1 + 2 + 3 + 4 + 5</p>
  
  <p>21 = 1 + 2 + 3 + 4 + 5 + 6</p>
  
  <p>etc.</p>
  
  <p>The series begins with 1 (the first triangular number). To calculate the nth triangular number, n is
  added to the previous triangular number. For example, the fourth triangular number is calculated
  by adding 4 to the third triangular number (which is 6), i.e. 10 = (1 + 2 + 3) + 4.</p>
  
  <p>So far, this is what I've come up with:</p>
  
  <pre><code>int triNum(n)
  {
      if (n&lt;=1)
          return n;
  
      int num = 0;
  
      for (int i = 0; i &lt; n; i++)
      {
          num = n + triNum(n-1)
      }
      return num;
  }
  </code></pre>
  
  <p>However I'm not sure that this is the correct answer, can anyone help guide me how I should approach this problem?</p>