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:
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Find the next fibonacci number
- Find the next Non-Fibonacci number
- Program to find Nth odd Fibonacci Number
- Program to find last two digits of Nth Fibonacci number
- Find nth Fibonacci number using Golden ratio
- Find Index of given fibonacci number in constant time
- Array range queries to find the maximum Fibonacci number with updates
- 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
- Previous perfect square and cube number smaller than number N
- Number of ways to represent a number as sum of k fibonacci numbers
- Find the sum of first N odd Fibonacci numbers
- Finding number of digits in n'th Fibonacci number
- Find two Fibonacci numbers whose sum can be represented as N
- Find the GCD of N Fibonacci Numbers with given Indices
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.