find the fibonancy series using C# Program

find the fibonancy series using C# Program

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

namespace Fibonancy_series
{
    class Program
    {
        public static int fibonancy(int n)
        {
            int a = 0;
            int b = 1;
            for (int i = 0; i < n; i++)
            {
              int  temp = a;
                a = b;
                b = temp + b;

            }
            return a;
        }
        static void Main()
        {
            for (int i = 0; i < 15; i++)
            {
                Console.WriteLine(fibonancy(i));
                Console.ReadLine();
       }
}

OutPut : following o/p display first 15 fibonancy series






Previous
Next Post »