Given a number n, the task is to print first n Fibonacci numbers.
Prerequisite : Program to print first n Fibonacci Numbers | Set 1
Input : 7 Output :0 1 1 2 3 5 8 Input : 5 Output :0 1 1 2 3
N-th Fibonacci Number = [(1 + √5)n – (1 – √5)n)] / [2n * √5]
Below is the implementation.
0 1 1 2 3 5 8 13
Note : The above program is costly compared to method 1 as it causes power computations in floating point. Also, it may not work perfect due to floating point precision errors.
- Program to print first n Fibonacci Numbers | Set 1
- Program to print Fibonacci Triangle
- Print Fibonacci sequence using 2 variables
- Print Fibonacci Series in reverse order
- C++ Program to print Fibonacci Series using Class template
- Non Fibonacci Numbers
- Even Fibonacci Numbers Sum
- Sum of Fibonacci Numbers
- GCD and Fibonacci Numbers
- The Magic of Fibonacci Numbers
- Prime numbers and Fibonacci
- Program for Fibonacci numbers
- C Program for Fibonacci numbers
- Sum of squares of Fibonacci numbers
- Find the sum of first N odd 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.