C# Program - Fibonacci Series | Digital Infotainment

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a=0, b=1, c, n;
            Console.Write("Enter a number");
            n = int.Parse(Console.ReadLine());
            Console.Write("The fibonacci series of the number is:");
            Console.Write(" "+a);
            Console.Write(" "+b);
            c=a+b;
            do
            {
                Console.Write(" " + c);
                a = b;
                b = c;
                c = a + b;
            } while (c <= n);
            Console.ReadKey();
        }
    }
}

/*Do leave a comment if you find this useful*/

No comments:

Post a comment