Open In App

GFact | Finding nth Fibonacci Number using Golden Ratio

Last Updated : 17 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report
We have discussed different methods to find nth Fibonacci Number. Following is another mathematically correct way to find the same. nth Fibonacci Number :  F(n) = \left \lfloor \frac{\varphi^n}{\sqrt5} + \frac{1}{2} \right \rfloor, n >= 0 Here φ is golden ratio with value as (\sqrt 5+1)/2 The above formula seems to be good for finding nth Fibonacci Number in O(Logn) time as integer power of a number can be calculated in O(Logn) time. But this solution doesn’t work practically because φ is stored as a floating point number and when we calculate powers of φ, important bits may be lost in the process and we may get incorrect answer. References: https://www.youtube.com/watch?v=-EQTVuAhSFY http://en.wikipedia.org/wiki/Fibonacci_number

Similar Reads

Find nth Fibonacci number using Golden ratio
Fibonacci series = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ........Different methods to find nth Fibonacci number are already discussed. Another simple way of finding nth Fibonacci number is using golden ratio as Fibonacci numbers maintain approximate golden ratio till infinite. Golden ratio: [Tex]\varphi ={\frac {1+{\sqrt {5}}}{2}}=1.6180339887\ldots [/T
6 min read
Deriving the expression of Fibonacci Numbers in terms of golden ratio
Prerequisites: Generating Functions, Fibonacci Numbers, Methods to find Fibonacci numbers. The method of using Generating Functions to solve the famous and useful Fibonacci Numbers' recurrence has been discussed in this post. The Generating Function is a powerful tool for solving a wide variety of mathematical problems, including counting problems.
4 min read
Why the value of Golden Ratio is 1.618 and how is it related to Binet's formula ?
Golden Ratio: Two numbers, say A and B are said to be in the golden ratio if their ratio equals the ratio of the sum of two numbers to the larger number, i.e., Suppose A > B, thenIf A/B = (A + B)/A = ∅ = 1.618(Golden Ratio), then these two numbers are said to be in golden ratio. It is denoted by ∅ and its value is equal to 1.6180339..., which is
3 min read
Check if a M-th fibonacci number divides N-th fibonacci number
Given two numbers M and N, the task is to check if the M-th and N-th Fibonacci numbers perfectly divide each other or not.Examples: Input: M = 3, N = 6 Output: Yes F(3) = 2, F(6) = 8 and F(6) % F(3) = 0 Input: M = 2, N = 9 Output: Yes A naive approach will be to find the N-th and M-th Fibonacci numbers and check if they are perfectly divisible or n
8 min read
GFact | 6 Digit number always divisible by 7, 11 and 13 when formed by repeating a 3-digit number twice
The statement "If we repeat a three-digit number twice, to form a six-digit number, the result will be divisible by 7, 11, and 13" is a mathematical property in number theory and mathematics. By repeating a three-digit number twice, we get a six-digit number having the last three digits the same as the first three digits. The number formed is divis
3 min read
Nth Fibonacci number using Pell's equation
Given an integer N, the task is to find the Nth Fibonacci number. Examples: Input: N = 13 Output: 144 Input: N = 19 Output: 2584 Approach: The Nth Fibonacci number can be found using the roots of the pell's equation. Pells equation is generally of the form (x2) - n(y2) = |1|. Here, consider y2 = x, n = 1. Also, taken positive (+1) in the right-hand
4 min read
Find Nth Fibonacci Number using Binet's Formula
Given a number n, print n-th Fibonacci Number, using Binet's Formula. Examples: Input: n = 5 Output: 1 Input: n = 9 Output: 34 What is Binet's Formula?Binet's Formula states that: If [Tex]F_n[/Tex] is the [Tex]n_{th}[/Tex] Fibonacci number, then[Tex] F_{n} = \frac{1}{\sqrt{5}}\left ( \left ( \frac{1+\sqrt{5}}{2} \right )^{n} - \left ( \frac{1-\sqrt
3 min read
Check if sum of Fibonacci elements in an Array is a Fibonacci number or not
Given an array arr[] containing N elements, the task is to check if the sum of Fibonacci elements of the array is a fibonacci number or not.Examples: Input: arr[] = {2, 3, 7, 11} Output: Yes Explanation: As there are two Fibonacci numbers in the array i.e. 2 and 3. So, the sum of Fibonacci numbers is 2 + 3 = 5 and 5 is also a Fibonacci number. Inpu
7 min read
GFact | Cayley's formula for Number of Labelled Trees
Consider below questions. How many spanning trees can be there in a complete graph with n vertices? How many labelled Trees (please note trees, not binary trees) can be there with n vertices? The answer is same for both questions. For n = 2, there is 1 tree. For n = 3, there are 3 trees. For n = 4, there are 16 trees The formula states that for a p
1 min read
C/C++ Program for nth multiple of a number in Fibonacci Series
Given two integers n and k. Find position the n'th multiple of K in the Fibonacci series. Examples: Input : k = 2, n = 3 Output : 9 3'rd multiple of 2 in Fibonacci Series is 34 which appears at position 9. Input : k = 4, n = 5 Output : 30 5'th multiple of 4 in Fibonacci Series is 832040 which appears at position 30. An Efficient Solution is based o
4 min read
Article Tags :
Practice Tags :