title: Writing Fibonacci sequence in Java starting from certain term
body: <p>I am trying to write a Fibonacci sequence generator based on Java. I saw many examples on the Internet for instance:</p>
  
  <pre><code>public class Fibonacci {
  
      public static void main(String[] args) {
          generateFibonacci(20);  // generate the first 20 fibonacci numbers
      }
  
      public static void generateFibonacci(long limit) {
          long first = 0;
          long second = 1;
          System.out.print(first+", "+second);
          for(long i=1;i&lt;limit;i++) {
              long next = first + second;
              System.out.print(", "+next);
              first = second;
              second = next;
          }
          System.out.println();
      }
  
  }
  </code></pre>
  
  <p>And it works fine. The problem is that not only I want to generate the first 20 numbers, but I also need to specify a starting point. For example:</p>
  
  <pre><code>public List&lt;Long&gt; generateFibonacci(long startFrom, long numberTerms) {
  
  }
  </code></pre>
  
  <p>Doing:</p>
  
  <pre><code>generateFibonacci(5, 10);
  </code></pre>
  
  <p>Should output:
  8l<br>
  13l 
  21l 
  34l 
  55l 
  89l 
  144l
  233l
  377l</p>
  
  <p>I have tried the following code but it doesnt seem to be performing the desired action:</p>
  
  <pre><code>public class example {
      public static void main(String[] args) {
          generateFibonacci(10, 5); 
      }
  
      public static void generateFibonacci(long limit, long startPoint) {
          long first = 0;
          long second = 1;
          long endPoint = startPoint + limit;
          System.out.print(first + ", " + second);
          for (long i = 1; i &lt; endPoint; i++) {
              long next = first + second;
              if (i &gt; startPoint) {
                  System.out.print(", " + next);
              }
              ;
              System.out.print(", " + next);
              first = second;
              second = next;
          }
      }
  }
  </code></pre>
  
  <p>Any ideas on how to achieve this in an efficient way?</p>