{{#items}}

{{text}}

{{/items}} {{ctaText}}

{{#items}} {{/items}}

showing results for - "fibonacci series in c 2b 2b using dynamic programming"

Robin

17 Sep 2016

```
1# Fibonacci Series using Dynamic Programming
2def fibonacci(n):
3
4 # Taking 1st two fibonacci numbers as 0 and 1
5 f = [0, 1]
6
7
8 for i in range(2, n+1):
9 f.append(f[i-1] + f[i-2])
10 return f[n]
11
12print(fibonacci(9))
13
```

Sophia

18 Mar 2020

```
1#include<bits/stdc++.h>
2using namespace std;
3
4class GFG{
5
6public:
7int fib(int n)
8{
9
10 // Declare an array to store
11 // Fibonacci numbers.
12 // 1 extra to handle
13 // case, n = 0
14 int f[n + 2];
15 int i;
16
17 // 0th and 1st number of the
18 // series are 0 and 1
19 f[0] = 0;
20 f[1] = 1;
21
22 for(i = 2; i <= n; i++)
23 {
24
25 //Add the previous 2 numbers
26 // in the series and store it
27 f[i] = f[i - 1] + f[i - 2];
28 }
29 return f[n];
30 }
31};
32
33// Driver code
34int main ()
35{
36 GFG g;
37 int n = 9;
38
39 cout << g.fib(n);
40 return 0;
41}
42
43// This code is contributed by SoumikMondal
```

similar questions

memoization fibonacci c 2b 2btribonacci series c 2b 2bfibonacci in c 2b 2bfibonacci numbers in c 2b 2bfibonacci series in c 2b 2bfibonacci sequence c 2b 2bfibbonaci c 2b 2bc 2b 2b fibonaccic 2b 2b program to print fibonacci seriesfibonacci series in c 2b 2b recursivec 2b 2b allocate and free dynamic 2d arrayprogram to calculate fibonacci of 100 in c 2b 2bdynamic programming with code implementation in c 2b 2bc 2b 2b print out first 6 fibonacci numbers your answer for

you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content

please ensure to add code which is syntactically corrent and executes properly

ask question on maxinterview

you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content

please be clear, to the point and respectful