Add

Fibonacci Series Program in Java

11:18:00 AM Rohit Kumar Verma 0 Comments

Fibonacci Series Program in Java

In Fibonacci Series is the sum of the previous 2 numbers for eg.  0 1 1 2 3 5 8 13 21 34.......


class FibonacciSeries{
public static void main(String[] args)
{  
int no1=0,no2=1,no3,i, input=10;  
System.out.print(no1+" "+no2);  
    for(i=2;i<input;++i)
{  
 no3=no1+no2;  
 System.out.print(" "+no3);  
 no1=no2;  
 no2=no3;  
}  
}
}  

0 comments: