title: Given the following series... the nth term of the series equals to (n - 1)th ^2 +1 and the first term of the series is 1 use recursion
body: <p>Given the following series: 1, 2,5,26,677,
  ..... such that the nth term of the series equals to 
  (n-1)th ^2 +1 and the first term of the series is 1. 
  Write a program using recursive function named f to compute the nth term. Use for loop to print the 
  values of f
  irst n terms in the series. You will take input n from the user.</p>
  
  <p>Can anyone help me figure out what the hell I'm doing here? I am not sure how to do this with recursion, I know how to do it without.</p>
  
  <p>Thanks,
  t</p>
  
  <p>EDIT: I've got it to do the sequence now, <strong>I just don't know how to fix it where there is a for loop that does the first 5 of this sequence and then the recursion function does the rest:</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  
  double f(double n);
  
  int main(){
  /*
      Problem 6:
      - Recursive function to generate nth term of f(x)
  */
  
  double nth;
  int i = 0,flag=1;
  double result;
  int seq[] = {1,2,5,26,677};
  
  printf("Please enter the number of terms you would like to generate: 
  
  \n");
  
      while(flag == 1){
          if(scanf("%lf",&amp;nth) == 1){
              flag = 0;
          }
          else{
              printf("Invalid number, program is exiting...\n");
              return 0;
          }
      }
  
      result = f(nth);
  
      return 0;
  }
  
  
  double f(double n){
      // base condition
      if(n == 1)
          return 1;
      else
          printf("(%.0lf)",pow(f(n-1),2.0) + 1);
  }
  </code></pre>