In mathematics, the Fibonacci numbers, commonly denoted Fₙ form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is, and for n > 1. One has F₂ = 1.
Fibonacci Sequence is the series of numbers:
1 2 3 |
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, ... |
Program: Fibonacci Series in Java Without Recursion
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
class FibonacciExample1{ public static void main(String args[]) { int n1=0,n2=1,n3,i,count=10; System.out.print(n1+" "+n2);//printing 0 and 1 for(i=2;i<count;++i)//loop starts from 2 because 0 and 1 are already printed { n3=n1+n2; System.out.print(" "+n3); n1=n2; n2=n3; } }} |
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.