Marine biologists model the growth of a particular coral colony month by month. In the colony's very first month it produces 0 new branches, and in its second month it produces exactly 1 new branch. From the third month onward, biologists have observed that the number of new branches produced in a given month always equals the sum of the new branches produced in the two immediately preceding months.
Given the number of months to simulate, report the new-branch count for every month from the first through the last, in order.
A single integer n — the number of months to report.
Print n integers separated by single spaces on one line: the new-branch counts for months 1 through n, in order.
Example 1
Input
1
Expected
0
Explanation
With only one month to report, the output is just the first term, which is defined to be 0.
Example 2
Input
8
Expected
0 1 1 2 3 5 8 13
Explanation
Month 1 is 0 and month 2 is 1 by definition. Each later month is the sum of the two before it: month 3 = 0+1 = 1, month 4 = 1+1 = 2, month 5 = 1+2 = 3, month 6 = 2+3 = 5, month 7 = 3+5 = 8, month 8 = 5+8 = 13. Printing all eight terms in order gives "0 1 1 2 3 5 8 13".
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →