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
- Print Fibonacci sequence using 2 variables
- Program to print Fibonacci Triangle
- Print Fibonacci Series in reverse order
- C++ Program to print Fibonacci Series using Class template
- Even Fibonacci Numbers Sum
- GCD and Fibonacci Numbers
- Non Fibonacci Numbers
- Sum of Fibonacci Numbers
- Sum of Fibonacci Numbers in a range
- Sum of squares of Fibonacci numbers
- The Magic of Fibonacci Numbers
- Alternate Fibonacci Numbers
- Prime numbers and Fibonacci
- 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.