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:
- Numbers with a Fibonacci difference between Sum of digits at even and odd positions in a given range
- Check if sum of Fibonacci elements in an Array is a Fibonacci number or not
- Check if a M-th fibonacci number divides N-th fibonacci number
- Sum of cubes of first n odd natural numbers
- Sum of first n odd numbers in O(1) Complexity
- Sum of square of first n odd numbers
- Sum of fourth powers of first n odd natural numbers
- Sum of range in a series of first odd then even natural numbers
- Sum of elements in range L-R where first half and second half is filled with odd and even numbers
- Program to find Nth odd Fibonacci Number
- Program to print first n Fibonacci Numbers | Set 1
- Print first n Fibonacci Numbers using direct formula
- Find two Fibonacci numbers whose sum can be represented as N
- Find n terms of Fibonacci type series with given first two terms
- Average of odd numbers till a given odd number
- Count of N-digit Numbers having Sum of even and odd positioned digits divisible by given numbers
- Check if the n-th term is odd or even in a Fibonacci like sequence
- Average of first n odd naturals numbers
- Count numbers in given range such that sum of even digits is greater than sum of odd digits
- Sum of Fibonacci Numbers
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.