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
- Non Fibonacci Numbers
- GCD and Fibonacci Numbers
- Even Fibonacci Numbers Sum
- Sum of Fibonacci Numbers
- Find the sum of first N odd Fibonacci numbers
- C Program for Fibonacci numbers
- Prime numbers and Fibonacci
- Sum of squares of Fibonacci numbers
- Sum of Fibonacci Numbers in a range
- Program for Fibonacci numbers
- The Magic of 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 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.