Fibonacci Sequence
Time limit: 5000ms
Memory limit: 256mb
Description:
The Fibonacci sequence is 0, 1, 1, 2, 3, 5, 8, ...
The sequence f(n) is defined by the recurrence relation:
f(n) = f(n-1) + f(n-2) with f(0) = 0 and f(1) = 1.
Use recursion to calculate the sum of the first n Fibonacci numbers.
Input:
One non-negative integer n.
Output:
You should output only one line which contains the sum of the first n Fibonacci numbers (n <= 20).
Sample input:
3
Sample output:
4
Hint:
f(0) + f(1) + f(2) + f(3) = 0 + 1 + 1 + 2 = 4
Submit