Skip to main content

Fibonacci Series using Dynamic Programming #include

// Fibonacci Series using Dynamic Programming 
#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 = 9; 

    printf("%d", fib(n)); 

    getchar(); 

    return 0; 

Comments

Popular posts from this blog

Classification of Networks Based on Geographical Classification

               ***Classification of Networks Based on Geographical Classification***                   In this section ,we will discuss the following categories of networks.                                                                                                                 PAN ...

Types of server, all types of server file server, print server, application server, database server, message server information.

                                                                                                                    Types of Servers Hi today’s blog is on types of Servers. You can take knowledge of types of servers blog in marathi मराठी. Link https://myblogs0727.blogspot.com/2020/05/blog-post_11.html?m=1 Servers are those who connects us to the internet or links us to a good internet (net) service that we uses the connection of the service.        Server is the thing that serves the service to us i.e. end users, in other words it plays roll like servant which serves us ...

Blog on computer network

computer network BLOGGER.COM           ****   Blog On Computer Network***                                                                                      PART-1.         computer network is nothing but, the network that is spread in our environment. network is a broad term similar to "system". Network is communication system which supports many users. computer network system| computer networking system server types        this link is for server types blog in english,, and in its comment section it is in marathi also              The interconnection of one station to many stations is called as networking.           ...