# Classic algorithm details (2): February Series

Source: Internet
Author: User

Classic algorithm details (2): February Series

Note:

Fibonacci is a european mathematician in the 1200 s. In his book, he once mentioned that if one child is born every month, a child is also produced after one month. At first, there was only one free Sub-Account, two free sub-accounts in one month, and three free sub-accounts in two months, five free sub-accounts after three months (small sub-accounts are put into production )....... If you don't quite understand this example, you can see it in the figure below. Note that it takes only one month for a new child to be involved in production. A similar principle can also be used for plant growth, this is the Fibonacci series, which is generally referred to as the Fei's series, for example: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 ......

Analysis:

If we look for the law of the February number in mathematics, it is easy to find that when n> = 2, f (n) = f (n-1) + f (n-2 ). But why is there a logic analysis rule? In fact, it is very simple because the number of rabbits in the nth month = the number of rabbits in the previous month + the number of new rabbits in this month. The number of rabbits in the previous month is f (n-1). What is the number of new rabbits in the previous month, because only rabbits that existed last month can be born this month, so the number of new rabbits is f (n-2 ).

Implementation:

```/*************************************** * ************************* Name: gossipAlgorithm. c Description: the problem is a classical recursion problem Author: fuchencong@163.com Time: *************************************** * ************************/# include

Const int MAX_SIZE = 20; int main () {int arrayGossip [MAX_SIZE]; arrayGossip [0] = 0; /** the first element of array is 0 */arrayGossip [1] = 1; for (int I = 2; I

Summary:

The Fisher series can easily find out its laws in mathematics, but if you want to understand it logically, you have to think a little bit.

```
Related Keywords:
Related Article

### Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.