0 , 1 , 1 , 2, 3 , 5 , 8 , 13 , …………..
class fibonacci{
public static void main(String args[])
{
int n=Integer.parseInt(args[0]);
int f=0,s=1;
int cur;
System.out.print(f+" "+s+" ");
do{
cur=f+s;
f=s;
s=cur;
System.out.print(cur+" ");
}while(cur
}
}
No comments:
Post a Comment