title: I want to generate fibonacci series. Here is my code it is not generating the required fibonacci series
body: <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int fib(int x)
  {
      int number1 = 0;
      int number2 = 1;
      int next = 0;
      for (int i = 0 ; i &lt; x-1 ; ++i)
      {
          next = number1 + number2;
          number2 = next;
      }
      return next;
  }
  int main()
  {
      int n = 40;
      cout &lt;&lt; fib(n);
      return 0;
  }
  </code></pre>
  <p>Please tell me what I did wrong. It is not generating the series I want. I want to generate fibonacci series from a given number.</p>