Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Welcome to GDB Online.
- GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, HTML, CSS, JS.
- Code, Compile, Run and Debug online from anywhere in world.
- *******************************************************************************/
- #include <stdio.h>
- #include <iostream>
- using namespace std;
- #include<stdio.h>
- int fib(int n)
- {
- /* Declare an array to store Fibonacci numbers. */
- int f[n+1];
- int i;
- /* 0th and 1st number of the series are 0 and 1*/
- f[0] = 0;
- f[1] = 1;
- for (i = 2; i <= n; i++)
- {
- /* Add the previous 2 numbers in the series
- and store it */
- f[i] = f[i-1] + f[i-2];
- }
- return f[n];
- }
- int main ()
- {
- int n = 7;
- printf("%d", fib(n));
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement