C# Generate Fibonacci Series

In mathematics, the Fibonacci numbers, commonly denoted Fn form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,

{\displaystyle F_{0}=0,\quad F_{1}=1,}

and

{\displaystyle F_{n}=F_{n-1}+F_{n-2},}

for n > 1.

One has F2 = 1. In some books, and particularly in old ones, F0, the “0” is omitted, and the Fibonacci sequence starts with F1 = F2 = 1. The beginning of the Fibonacci sequence is thus:

{\displaystyle (0,)\;1,\;1,\;2,\;3,\;5,\;8,\;13,\;21,\;34,\;55,\;89,\;144,\;\ldots }

(wiki)

 

using System;

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            int i, count, f1 = 0, f2 = 1, f3 = 0;

            Console.Write("Enter the Limit: ");
            count = Convert.ToInt16(Console.ReadLine());

            Console.WriteLine(f1);
            Console.WriteLine(f2);

            for (i = 0; i <= count; i++)
            {
                f3 = f1 + f2;
                Console.WriteLine(f3);
                f1 = f2;
                f2 = f3;
            }

            Console.ReadLine();

        }
    }
}

 

Output