-->
当前位置:首页 > 题库

PROGRAMMING:Output the first n terms of Fibonacci sequence

Luz5年前 (2021-05-10)题库436
It is known that the law of Fibonacci sequence is 1, 1, 2, 3, 5, 8,..., that is, the first two terms of the sequence are 1, and each of the subsequent terms is the sum of the first two terms. Output the first n (1 < = n < = 40) items of Fibonacci sequence. It is required to define and call the function Fibonacci (n) with static variables to calculate the nth item of Fibonacci sequence.
###Input format:
Enter the n value
###Output format:
Output the first n items of Fibonacci sequence in the format of 4 items per line. Each item is 10 bits wide and left aligned.
###Input example:
Here is a set of inputs. For example:
```in
ten
```
###Output example:
The corresponding output is given here. For example:
```out
1 1 2 3
5 8 13 21
34 55
```







answer:If there is no answer, please comment