# C++ program to find Fibonacci number using different methods

**Fibonacci numbers are the numbers having a specific sequential pattern.**

**0 , 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34, ...** this type of sequence follow a mathematical pattern.

Fn = Fn-1 + Fn-2 , where F0 = 0 , F1 = 1

Where **n** = 2,3,4,5,6,7,8, ...

## 1. Using recursion method

In recursion a lot work is done as it repeatedly calculates the number and solves same case more than one time.

For Example:As it calculates Fibo(1) & Fibo(0) multiple timeConsider the program:Output

## 2. Using Dynamic programming method

A dynamic programming algorithm remembers the past result and uses them to find new result means it solve complex problems by breaking it down into a collection of simpler subproblems, then solving each of those subproblems only once ,and storing their solution for future use instead of recomputing their solutions again.

Algorithm:Consider the program:Output

## 3. Without using array

Well it is the easiest way to calculate Fibonacci number as we just have to add two previous numbers to calculate next number.

Consider the program:Output

need an explanation for this answer? contact us directly to get an explanation for this answer