Thursday, 19 September 2013

Console Application : Fibonacci Series.

Create new Console Application Project And Name It As FibonacciSeries.
Now Just Change Your Program.cs With Below Code.

Program.cs


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

namespace FibonacciSeries
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Series Upto..?");

            int d = int.Parse(Console.ReadLine());

            int a = -1; int b = 1;

            for (int i = 0; i < d; i++)
            {
                int sum = b + a; a = b;
                b = sum;
                Console.WriteLine(b);
            }
            Console.WriteLine("Type and enter to close.");
            Console.ReadLine();
           
        }
    }
}
 

Now Compile And Run The Project.
Enter The Term Upto Which We Want The Fibonacci Series.

My Output's Are As Below.





  All The Best :)

No comments:

Post a Comment