Java Program to find the Fibonacci Sequence


Couch ModePrint

/**Java Program to find the Fibonacci Sequence **/

Change the Count=5 to How Much Fibonacci series you need. Default Program is set to 5

class Fibonacci
{  
public static void main(String args[])  
{    
 int n1=0,n2=1,n3,i,count=5;    
 System.out.print(n1+" "+n2); 
 for(i=2;i<count;++i)
 {    
  n3=n1+n2;    
  System.out.print(" "+n3);    
  n1=n2;    
  n2=n3;    
 }     
}
}  

Thank Your Valuable Comment Tool to Insert codes in Comments : Convert My Code. Hide

Select to parse the code (not required if code is already parsed):

Subscribe By Email

Join Our Newsletter

Get All The Latest Updates Delivered Straight Into Your Inbox For Free!

We Respect Your Privacy

Popular Posts