WHAT'S NEW?
Loading...

Fibonacci Program

import java.util.*;

class fibonacci
{
	 public static void main(String args[])
	 {
	 	int n,i,fn=0,sn=1,tn;
	 	Scanner din=new Scanner(System.in);
	 	System.out.println("Enter a no.");
	 	n=din.nextInt();

	 	System.out.println("Fibonacci Series :");
	 	for(i=0;i<=n;i++)
	 	{
	 		tn=fn+sn;
	 		System.out.println(tn);
	 		fn=sn;
	 		sn=tn;

	 	}

	 }
}
Post a Comment