Example 32: Fibonacci Series

Learn how to print a Fibonacci series.


Fibonacci series is a series in which each number is the sum of the two preceding ones, starting from 1 and 1.

F0=1F_{0} = 1

F1=1F_{1} = 1


Write a program to print the first 10 terms of the Fibonacci series.


Input Output
Nil 1   1   2  3  5  8  13  21  34  55

Try it yourself

Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.