import java.util.Scanner;
/**
*
* @author pankaj
*/
public class Fibonicci
{
public static void main(String[] args)
{
System.out.print("enter the number till you want fibonicci series : ");
Scanner in=new Scanner(System.in);
int num=in.nextInt();
int a=0,b=1,i=0,c=0;
while(i!=num)
{
System.out.print("\n"+c+ " ");
a=b;
b=c;
c=a+b;
i++;
}
}
}
No comments:
Post a Comment