title: How to get fibonacci in c#
body: <p>Guys I have a question regarding on fibonacci..How do I get the fibonacci series that the number will also end on user input...example if I put 21 the output must be 0 1 1 2 3 5 8 13 21</p>
  
  <p>This is my code</p>
  
  <pre><code>    static void Main(string[] args)
      {
  
          int input, first = 0, second = 1, third = 0;
          Console.Write("Enter a number : ");
          n = Convert.ToInt32(Console.ReadLine());
          Console.Write("First {0} Fibonacci numbers {1} {2} ", input, first, second);
  
          for (int i = 3; i &lt;= input; i++)
          {
              third = first + second;
              Console.Write("{0} ", third);
              first = second;
              second = third;
          }
  
  
      }
  </code></pre>