Mar 20, 2010

Java Program for printing the Fibonacci Series

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++;
            }
    }
}

1 comment: