what is fibonacci series, create a program in C# ?

0 votes
155 views
Saziya Khan asked 11-Sep-2018 in programming by Saziya Khan

1 Answer

0 votes
Sanat Shukla answered 12-Sep-2018 by Sanat Shukla

Fibonacci Series

what is fibonacci series, create a program in C# ?


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Fibonacci
{
    class Program
    {
        static void Main(string[] args)
        {
            int i, count, f1 = 0, f2 = 1, f3 = 0;
            Console.Write("Enter the Limit : ");             count = int.Parse(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();
        }
    }
}