title: Java Fibonacci Series - Return Values in Array
body: <p>I'm trying to recursively compute the fibonacci sequence to 100, store those returned values into an array using a the buildArray method, then print values stored in the array. I am getting a "cannot be resolved to a variable" compilation error when I try to print A[N] in the main method. I'm using longs because I'm computing the series up to 100, although I don't know if it's necessary to use longs.</p>
  
  <p>If I substitute F(N) for A[N] the code works, but I need to put the values into an array and print that array. Does this code even store the values in an array? I'm just starting java, thanks.</p>
  
  <pre><code>public class MyFibonacci {
      public static final int MAX = 100;
  
      public static long[] buildArray(int MAX, int N) {
          long[] A = new long[MAX];
  
          A[0] = 0;
          A[1] = 1;
  
          for(N = 2; N &lt; MAX; N++)
              A[N] = F(N);
          return A;
      }
  
      public static long F(int N) {
          if(N == 0)
              return 0;
          if(N == 1)
              return 1;
          return F(N - 1) + F(N - 2);
      }
  
      public static void main(String[] args) {
          for(int N = 0; N &lt; MAX; N++)
              System.out.println(N + " " + A[N]);
      }
  }
  </code></pre>