  Showing: Handle Score
@Ibrahim Nash 6560
@mb1973 5777
@Quandray 5275
@akhayrutdinov 5111
@saiujwal13083 5074
@kirtidee18 4398
@sanjay05 3762
@mantu_singh 3654
@gfgaccount 3601
@marius_valentin_dragoi 3525
Fibonacci Sum
Easy Accuracy: 31.66% Submissions: 1555 Points: 2

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.

Example 1:

Input:
N = 3
Output:
4
Explanation:
0 + 1 + 1 + 2  = 4


Example 2:

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)

Constraints:
1 <= N <= 100000

### Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

#### My Submissions:  