The Fibonacci series refers to a series of numbers: 1, 1, 2, 3, 5, 8, 13, 21 ,......
If F (n) is set to the nth item of the series (N, N + ). Then this sentence can be written as follows: F (0) = 0, F (1) = 1, F (n) = f (n-1) + f (n-2) (N ≥ 2 );
General Formula: F (n) = (√ 5/5) * {[(1 + √ 5)/2] ^ N-[(1-√ 5)/2] ^ n}
Such a series is completely a natural number, but the general formula is expressed by an irrational number.
Nature:
1. When n tends to be infinite, the fractional part of the ratio of the last item to the previous item is getting closer and closer to the Golden division of 0.618.
2. From the second item, the square of each odd number item is 1 more than the product of the first and second items, and the square of each even number item is 1 less than the product of the first and second items.
An interesting game:
Why 64 = 65? In fact, it uses this property of the Fibonacci series: 5, 8, and 13 are the adjacent three items in the series. In fact, the area of the two blocks before and after is indeed 1, however, there is a long slit in the figure below, which is not easy to notice.
3 The Nth entry of the Fibonacci series also represents the number of subsets in the {1, 2,..., n} set that do not contain adjacent positive integers.
4. Fibonacci series (f (N), F (0) = 0, F (1) = 1, F (2) = 1, F (3) = 2 ......) Other properties:
1. F (0) + F (1) + F (2) +... + F (n) = f (n + 2)-1.
2. F (1) + f (3) + f (5) +... + F (2n-1) = f (2n ).
3. F (2) + f (4) + f (6) +... + F (2n) = f (2n + 1)-1.
4. [F (0)] ^ 2 + [F (1)] ^ 2 +... + [F (n)] ^ 2 = f (n) · F (n + 1 ).
5. F (0)-f (1) + F (2 )-... + (-1) ^ N · F (n) = (-1) ^ N · [F (n + 1)-f (n)] + 1.
6. F (m + N-1) = f (S-1) · F (n-1) + f (m) · F (n ).
The Fibonacci series was introduced by the mathematician Leonardo Fibonacci using rabbit breeding as an example. It is also known as the "Rabbit series ".
Generally, a rabbit has the ability to breed after being born two months. A rabbit can have a rabbit every month. If all rabbits do not die, how many rabbits can breed in a year?
Let's take an analysis of the new BUNNY:
The first month of the rabbit was not capable of reproduction, so it was still a pair
Two months later, two pairs of rabbits were born.
Three months later, the old rabbit gave birth to another pair. Because the rabbit has no breeding ability, there are three
------
The following table can be listed by analogy:
Number of months |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
Child logarithm |
1 |
0 |
1 |
1 |
2 |
3 |
5 |
8 |
13 |
21 |
34 |
55 |
89 |
Rabbit logarithm |
0 |
1 |
1 |
2 |
3 |
5 |
8 |
13 |
21 |
34 |
55 |
89 |
144 |
Total logarithm |
1 |
1 |
2 |
3 |
5 |
8 |
13 |
21 |
34 |
55 |
89 |
144 |
233 |
Child logarithm = rabbit logarithm of the previous month
Adult Rabbit logarithm = previous month's adult rabbit logarithm + previous month's child logarithm
Total logarithm = number of rabbits in the current month + number of children in the current month
We can see that the young child's logarithm, the rabbit's logarithm, and the general logarithm constitute a series. This series has very obvious characteristics. That is: the sum of the two adjacent items above, which constitutes the next item.
The Fibonacci series in C ++:
// Output a Fibonacci sequence # include <iostream> # include <iomanip> using namespace STD; int main () {unsigned int val; cout <"enter a number, returns the Fibonacci sequence not greater than this number: "<Endl; CIN> val; If (Val> 4294967295 | Val <= 0) {cout <" overflow, enter 0 ~ Number between 4294967296 "<Endl; return 0;} unsigned int x = 0, y = 1, Z, cont = 1; Z = x + y; cout <SETW (12) <1; while (z <= Val) {cout <SETW (12) <z <""; X = y; y = z; Z = x + y; cont ++; If (cont % 6 = 0) cout <Endl; // one row for each six numbers} cout <Endl; return 0 ;}
The one above is limited, and then there is a large length, that is, the big number:
// Output a Fibonacci sequence # include <iostream> # include <string> # include <iomanip> using namespace STD; string add (string S1, string S2) {Int J, l, LA, Lb; string Max, min; max = S1; min = S2; If (s1.length () <s2.length () {max = S2; min = S1 ;} la = max. size (); lB = min. size (); L = La-1; for (j = lb-1; j> = 0; j --, l --) max [l] + = min [J]-'0'; For (j = La-1; j> = 1; j --) if (MAX [J]> '9') {max [J]-= 10; Max [J-1] ++;} If (MAX [0]> '9 ') {max [0]-= 10; max = '1' + Max;} return Max;} int main () {string val; cout <"enter a number, returns the Fibonacci sequence not greater than this number: "<Endl; CIN> val; int cont = 1; string x =" 0 ", y =" 1 ", Z; z = add (x, y); cout <"1" <Endl; while (Z. length () <Val. length () | (Z. length () = Val. length () & Z <Val) {cout <z <Endl; X = y; y = z; Z = add (x, y );} cout <Endl; return 0 ;}