follow A series of numbers in which each number is the sum of the two preceding numbers.

rencontres musicales de méditerranée bastia 2012 for example 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 etc. The first two numbers of fibonacci series are 0 and 1.

Algorithm: Step 1: START.

its its rencontre Step 2: Declare variables a,b,c.

enter Step 3: Initialize the variables.

Step 4: Enter no of terms of terms of fibonacci series to be printed.

Step 5: Print a,b.

Step 6: Use loop for the following steps

Step 7: Print c.

Step 8: STOP.

Source code:


This program calculates the Fibonacci series up to a limit and print the output back to the user.
The program has several variables –
  • a, b, c – These integer variables are used for the calculation of Fibonacci series. The values of a, b and c are initialized to 0, 1 and 0 respectively.
  • range – This integer is the limit determining the number of elements of Fibonacci series that should be calculated.
  • i – This is the loop variable.
First the user enters a limit. After that for loop takes the control and calculates the Fibonacci series up to the previously entered limit.
 The loop starts from 2 because 0 and 1 are already printed.

This process continues till the condition in the loop gets satisfied.



C:\Users\santo\Desktop\new>java Fibonacci


*** ***


<< JAVA program to Generate Fibonacci series >>


Enter the range:
0 1 1 2 3 5

Screenshot of Output:

Screenshot of output

Leave a Reply

Your email address will not be published. Required fields are marked *