Understanding Fibonacci Series C# – Expression & Code

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest

For programmers and developers, Fibonacci series is a common term that everyone learns with basics. To recall, Fibonacci series C# is a series of numbers wherein every number is a sum of the previous two. Starting with 0 and 1, the sequence is as 0, 1, 1, 2, 3, 5, 8, and so on.

General Expression and Program for Fibonacci Series C#

Written as a rule, the expression of Fibonacci series is Xn = Xn-1 + Xn-2. For clarification, below given is a program for the Fibonacci series C#.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace FibonaciDemo
{
    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();
 
        }
    }
}

 

Did you face any difficulty understanding the Fibonacci series C#, its expression, and code?  Share your comments and concerns in the below comment section.

[yikes-mailchimp form=”1″]

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on whatsapp
Share on email

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recommended for you
Connect With Us
Stay Connected
Subscribe to our newsletter today to receive updates on latest tech news, tutorials SEO tips many more.
Latest Articles