The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... The next number is found by adding up the two numbers before it. The 2 is found by adding the two numbers before it (1+1)
n1 | n2 | n3=n1+n2 |
0 | 1 | 1 |
1 | 1 | 2 |
1 | 2 | 3 |
and so on ..
Here
n1 becomes n2
and n2 becomes n3
int n1=0;
int n2=1;
int count=10;
int i;
System.out.print(n1+" "+n2);
for(i=2;i