How to solve Fibonacci series In java :-
What is Fibonacci series ?
The Fibonacci series is the sequence of numbers (also called Fibonacci numbers), where every number is the sum of the preceding two numbers, such that the first two terms are '0' and '1'. In some older versions of the series, the term '0' might be omitted. A Fibonacci series can thus be given as, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, . . . It can be thus be observed that every term can be calculated by adding the two terms before it.
Given the first term, F0 and second term, F1 as '0' and '1', the third term here can be given as, F2 = 0 + 1 = 1
Similarly,
F3 = 1 + 1 = 2
F4 = 2 + 1 = 3
INPUT:-
public class example{
public static void main(String args[]){
int i,j,k;
i=0;
j=1;
for(k=1;k<=100;k=j+i)
{
System.out.println(k);
i=j;
j=k;
}
}
}
0 Comments