• Source
    1. int fib(int n)
    2. {
    3. /* Declare an array to store Fibonacci numbers. */
    4. int f[n+1];
    5. int i;
    6.  
    7. /* 0th and 1st number of the series are 0 and 1*/
    8. f[0] = 0;
    9. f[1] = 1;
    10.  
    11. for (i = 2; i <= n; i++)
    12. {
    13. /* Add the previous 2 numbers in the series
    14.   and store it */
    15. f[i] = f[i-1] + f[i-2];
    16. }
    17.  
    18. return f[n];
    19. }