Given a number n then print n terms of fibonacci series in reverse order.
Input : n = 5 Output : 3 2 1 1 0 Input : n = 8 Output : 13 8 5 3 2 1 1 0
1) Declare an array of size n.
2) Initialize a and a to 0 and 1 respectively.
3) Run a loop from 2 to n-1 and store
sum of a[i-2] and a[i-1] in a[i].
4) Print the array in the reverse order.
3 2 1 1 0
- Count even length binary sequences with same sum of first and second half bits
- Longest Common Subsequence | DP-4
- Print Fibonacci sequence using 2 variables
- Program for Fibonacci numbers
- Subset with sum divisible by m
- Bell Numbers (Number of ways to Partition a Set)
- Tiling Problem
- Newman-Conway Sequence
- Alternate Fibonacci Numbers
- Sequences of given length where every element is more than or equal to twice of previous
- Print n terms of Newman-Conway Sequence
- Cutting a Rod | DP-13
- Find maximum length Snake sequence
- Maximum Length Chain of Pairs | DP-20
- Gold Mine Problem
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.
Improved By : jit_t