Given a number positive number N, find value of f0 + f1 + f2 + …. + fN where fi indicates i’th Fibonacci number.
Remember that f0 = 0, f1 = 1, f2 = 1, f3 = 2, f4 = 3, f5 = 5, …
Since the answer can be very large, answer modulo 1000000007 should be returned.
Input: N = 3 Output: 4 Explanation: 0 + 1 + 1 + 2 = 4
Input : N = 4 Output : 7 Explanation : 0 + 1 + 1 + 2 + 3 = 7
You don't need to read input or print anything. Your task is to complete the function fibSum() which takes an integer N as input parameter and returns the sum of all the Fibonacci number from F0 to FN.
Expected Time Complexity: O(Log N)
Expected Space Complexity: O(1)
1 <= N <= 100000
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.