Program to Get Fibonacci Series in C#

This blog defines Fibonacci series code using C#.
 
//Output--1 1 2 3 5 8 13 21 34 55
class Program
{
     static void Main(string[] args)
     {
         myprog ob = new myprog();
         ob.fab(10);
         onsole.ReadLine();
     }
}
 
public void fab(int n)
{
     int a=0,b=1,sum=0;
     for (int i = 1; i <= n; i++)
    {
         sum = a + b;
         a = b;
         b = sum;
         Console.WriteLine(a);
    }
}
Ebook Download
View all
Learn
View all