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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Program to print first n Fibonacci Numbers | Set 1
- Program to implement Inverse Interpolation using Lagrange Formula
- Roots of the quadratic equation when a + b + c = 0 without using Shridharacharya formula
- Check if a M-th fibonacci number divides N-th fibonacci number
- Check if sum of Fibonacci elements in an Array is a Fibonacci number or not
- Length of the direct common tangent between two externally touching circles
- Length of direct common tangent between the two non-intersecting Circles
- Length of direct common tangent between two intersecting Circles
- Ratio of the distance between the centers of the circles and the point of intersection of two direct common tangents to the circles
- Legendre's formula (Given p and n, find the largest x such that p^x divides n!)
- Program for Stirling Interpolation Formula
- Section formula (Point that divides a line in given ratio)
- Newton's Divided Difference Interpolation Formula
- Haversine formula to find distance between two points on a sphere
- Find the sum of first N odd Fibonacci numbers
- Print Fibonacci sequence using 2 variables
- C++ Program to print Fibonacci Series using Class template
- C Program to print Fibonacci Series without using loop
- Find n terms of Fibonacci type series with given first two terms
- Print squares of first n natural numbers without using *, / and -
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.