What is Fibonacci Series?
In Fibonacci series, next number is the sum of previous two numbers. The first two numbers of Fibonacci series are 0 and 1.
The Fibonacci numbers are significantly used in the computational run-time study of algorithm to determine the greatest common divisor of two integers.In arithmetic, the Wythoff array is an infinite matrix of numbers resulting from the Fibonacci sequence.
The Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, ...
In Fibonacci series, next number is the sum of previous two numbers. The first two numbers of Fibonacci series are 0 and 1.
The Fibonacci numbers are significantly used in the computational run-time study of algorithm to determine the greatest common divisor of two integers.In arithmetic, the Wythoff array is an infinite matrix of numbers resulting from the Fibonacci sequence.
The Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, ...
Program:
class Fibonacci_loop
{public static void main(String[] args)
{
// Set it to the number of elements you want in the Fibonacci Series
int maxNumber = 10;
int previousNumber = 0;
int nextNumber = 1;
System.out.print("Fibonacci Series of "+maxNumber+" numbers:");
for (int i = 1; i <= maxNumber; ++i)
{
System.out.print(previousNumber+" ");
/* On each iteration, we are assigning second number
* to the first number and assigning the sum of last two
* numbers to the second number
*/
int sum = previousNumber + nextNumber;
previousNumber = nextNumber;
nextNumber = sum;
}
}
}
Output:
Fibonacci Series of 10 numbers:0 1 1 2 3 5 8 13 21 34