Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6560 |

@blackshadows | 6400 |

@mb1973 | 5777 |

@Quandray | 5275 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5074 |

@kirtidee18 | 4398 |

@sanjay05 | 3762 |

@mantu_singh | 3654 |

@gfgaccount | 3601 |

@marius_valentin_dragoi | 3525 |

Complete Leaderboard | |

Handle | Score |

@anish5256 | 991 |

@vimleshpratapsingh321 | 980 |

@skj7 | 899 |

@akhileshkumar562002 | 862 |

@kanewilliamson123 | 854 |

@pradeeppatidar1999 | 852 |

@pd420786 | 813 |

@infilooop | 800 |

@bunnybug320 | 796 |

@smitabose7826 | 784 |

@wallflowe101 | 778 |

Complete Leaderboard |

Given a number positive number N, find value of f_{0} + f_{1} + f_{2} + …. + f_{N} where f_{i} indicates i’th Fibonacci number.

Remember that f_{0} = 0, f_{1} = 1, f_{2} = 1, f_{3} = 2, f_{4} = 3, f_{5} = 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
```

**Your Task:**

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 F_{0} to F_{N}.

**Expected Time Complexity:** O(Log N)

**Expected Space Complexity:** O(1)

**Constraints:**

1 <= N <= 100000

Login to report an issue on this page.

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

YesLoading...

Fibonacci Sum

...