Given a number, N. find the sum of first N odd Fibonacci numbers.
Note: The answer can be very large so print the answer modulo 10^9+7.
Input : N = 3 Output : 5 Expanation : 1 + 1 + 3 Input : 6 Output : 44 Explanation : 1 + 1 + 3 + 5 + 13 + 21
Odd Fibonacci series is:
1, 1, 3, 5, 13, 21, 55, 89......
Prefix sum of odd Fibonacci series is:
1, 2, 5, 10, 23, 44, 99, 188.....
The formula for the sum of first N odd Fibonacci numbers is:
a(n) = a(n-1) + 4*a(n-2) – 4*a(n-3) + a(n-4) – a(n-5) for n>5
Below is the implementation of the above approach:
- Find the GCD of N Fibonacci Numbers with given Indices
- GCD and Fibonacci Numbers
- Even Fibonacci Numbers Sum
- Non Fibonacci Numbers
- Sum of Fibonacci Numbers
- Prime numbers and Fibonacci
- Sum of squares of Fibonacci numbers
- Sum of Fibonacci Numbers in a range
- C Program for Fibonacci numbers
- The Magic of Fibonacci Numbers
- Program for Fibonacci numbers
- Alternate Fibonacci Numbers
- Sum of Fibonacci Numbers with alternate negatives
- Interesting facts about Fibonacci numbers
- Program to print first n Fibonacci Numbers | Set 1
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.