#K33482. Fibonacci Flower Heights
Fibonacci Flower Heights
Fibonacci Flower Heights
In this problem, you are given a series of test cases representing the number of flowers. Each flower grows following the Fibonacci sequence pattern. Specifically, the height of the first flower is , the second is also , and for , the -th flower's height is defined as:
Your task is to calculate the combined height of the first flowers, which is the sum:
For example:
- If $N = 1$, then the height is $1$.
- If $N = 3$, then the heights are $1, 1, 2$ and the combined height is $4$.
- If $N = 5$, then the heights are $1, 1, 2, 3, 5$ and the combined height is $12$.
Make sure your solution reads inputs from standard input and outputs the result for each test case to standard output.
inputFormat
The input begins with an integer , representing the number of test cases. Then lines follow; each line contains a single positive integer , the number of flowers.
outputFormat
For each test case, output a single integer representing the combined height (i.e. the sum of the first Fibonacci numbers) on a new line.## sample
3
1
3
5
1
4
12
</p>