Given a Fibonacci number N, the task is to find the previous Fibonacci number.
Input: N = 8
5 is the previous fibonacci number before 8.
Input: N = 5
Approach: The ratio of two adjacent numbers in the Fibonacci series rapidly approaches ((1 + sqrt(5)) / 2). So if N is divided by ((1 + sqrt(5)) / 2) and then rounded, the resultant number will be the previous Fibonacci number.
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check if a M-th fibonacci number divides N-th fibonacci number
- Check if sum of Fibonacci elements in an Array is a Fibonacci number or not
- Previous perfect square and cube number smaller than number N
- Elements greater than the previous and next element in an Array
- Maximum element in an array such that its previous and next element product is maximum
- Print the sequence of size N in which every term is sum of previous K terms
- Nth term of given recurrence relation having each term equal to the product of previous K terms
- Minimize replacements by previous or next alphabet required to make all characters of a string the same
- Find Index of given fibonacci number in constant time
- Program to find last two digits of Nth Fibonacci number
- Find nth Fibonacci number using Golden ratio
- Program to find Nth odd Fibonacci Number
- Find the next fibonacci number
- Find the next Non-Fibonacci number
- Array range queries to find the maximum Fibonacci number with updates
- Fast Doubling method to find the Nth Fibonacci number
- How to check if a given number is Fibonacci number?
- Finding number of digits in n'th Fibonacci number
- Number of ways to represent a number as sum of k fibonacci numbers
- Find n terms of Fibonacci type series with given first two terms
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.