Fibonacci Numbers

Fibonacci Series:


Fibonacci examples:

The Fibonacci sequence is named after Leonardo of Pisa, who was known as Fibonacci (a contraction of filius Bonacci, "son of Bonaccio").
Fibonacci's 1202 book Liber Abaci introduced the sequence to Western European mathematics, although the sequence was independently
described in Indian mathematics and it is disputed which came first.



The sequence of number 1, 1, 2, 3, 5, 8, 13, 21, 34 . . . . each of which sum is the sum of the two previous numbers.
These numbers are also called Fibonacci numbers. The ratio of one Fibonacci to the preceding one is a Convergent of the
 continued fraction.The sum of the Fibonacci Sequence can be directly obtained from Pascal's triangle.Fibonacci numbers are
 named after Leonardo of Pisa, known as Fibonacci. The Fibonacci numbers are also a Lucas sequence.Fibonacci numbers can be given by,

Fn = Fn-1 + Fn-2

where, F1 = F2 = 1
F0= 0 F1= 1 F2= 1 F3= 2 F4= 3
F5= 5 F6= 8 F7= 13 F8= 21 F9= 34
F10= 55 F11= 89 F12= 144 F13= 233 F14= 377

source : wikipedia


csharp / c# program for Fibonacci series recursive example :


class Program
    {
        static void Main(string[] args)
        {
          Program p=new Program();
          
            Console.Write(p.Fib(14));
            Console.ReadLine();
        }

        public int Fib(int num)
        {
            int res;
            if (num == 1 || num == 0)
                return num;
            res = Fib(num - 1) + Fib(num - 2);
            return res;
        }
    }


Output : 377


0 comments :

Post a Comment