In Fibonacci series, next number is the sum of previous two numbers.
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89.
class Fibonacci
{
public static void main(String args[])
{
int a=0, b=1, c=0, i;
System.out.print( a +" "+ b);
for(i=1;i<=10;i++)
{
c=a+b;
System.out.print(" "+c);
a=b;
b=c;
}
}
}
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89.
class Fibonacci
{
public static void main(String args[])
{
int a=0, b=1, c=0, i;
System.out.print( a +" "+ b);
for(i=1;i<=10;i++)
{
c=a+b;
System.out.print(" "+c);
a=b;
b=c;
}
}
}