Example 32: Fibonacci Series
Learn how to print a Fibonacci series.
We'll cover the following
Problem
Fibonacci series is a series in which each number is the sum of the two preceding ones, starting from 1 and 1.
Write a program to print the first 10 terms of the Fibonacci series.
Example
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 80+ hands-on prep courses.