Following is simple program to print first n Fibonacci numbers.
Input : n = 3 Output : 1 1 2 Input : n = 7 Output : 1 1 2 3 5 8 13
1 1 2 3 5 8 13
Time Complexity : O(n)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geekforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
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.
- Print first n Fibonacci Numbers using direct 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
- Find the sum of first N odd Fibonacci numbers
- Program to print Fibonacci Triangle
- C++ Program to print Fibonacci Series using Class template
- C Program to print Fibonacci Series without using loop
- C Program for Fibonacci numbers
- Program for Fibonacci numbers
- Find n terms of Fibonacci type series with given first two terms
- Print numbers such that no two consecutive numbers are co-prime and every three consecutive numbers are co-prime
- Print Fibonacci Series in reverse order
- Print Fibonacci sequence using 2 variables
- 3 Different ways to print Fibonacci series in Java
- Print squares of first n natural numbers without using *, / and -
- Print all increasing sequences of length k from first n natural numbers
- Print first N Mosaic numbers
- Print first K distinct Moran numbers from a given array
- Count Fibonacci numbers in given range in O(Log n) time and O(1) space
- Sum of Fibonacci Numbers