I. Question:Input N in the fastest wayFibonacciN of the number of columns.
Ii. Definition: the series of Fibonacci are as follows:
0 n = 0
F (n) = 1 n = 1, 2
F (n-1) + f (n-2) n> 2
// 0 1 1 2 3 5 8 13 21 34 55 144 233 377 610 9871597 ..........
Iii. Analysis:
Note: When you calculate 100th or even greater items, make sure that you use what type, long integer type? Orlong long int storage.
Otherwise, no results will be obtained from the computer. Therefore, the selected data type is critical.
4. Source Code:
# include <iostream> <br/> using namespace std; </P> <p> long Fibonacci (int n) <br/> {<br/> If (n> = 0) <br/>{</P> <p> If (0 = N) <br/> return 0; <br/> else if (1 = n | 2 = N) <br/> return 1; <br/> else <br/> return maid (n-1) + maid (n-2); <br/>}</P> <p> int main () <br/> {<br/> for (INT I = 0; I <10; I ++) <br/> cout <Fibonacci (I) <Endl; </P> <p> return 0; <br/>}