class Fibonacci
{
public static void main(String[] args)
{
int a=0,b=1,s=0;
System.out.println("Fibonacci series printing 10times:"); System.out.println(a);
System.out.println(b);
int i=0;
while(i<10)
{
s=a+b;
a=b;
b=s;
System.out.println(s);
i++;
}
}
}
Output:
ReplyDeleteFibonacci series printing 10times:
0
1
1
2
3
5
8
13
21
34
55
89