import java.io.*;
class Fibonacci
{ int next,curr,prev,num;
Fibonacci(int a)
{ next=1;
curr=1;
prev=0;
num=a;
}
void
calc()
{ while(prev<=num)
{ System.out.println(prev);
prev=curr;
curr=next;
next=prev+curr;
}
}
public
static void main(String s[])throws
IOException
{ BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Enter the limit");
int
a=Integer.parseInt(br.readLine());
Fibonacci f=new Fibonacci(a);
f.calc(); }
}
Output
|
Thank you for sharing this blog with some interesting topic keep doing this work also check out this Best CBSE School in Faridabad
ReplyDeleteWhat a wonderful blog it has everything and helps me to understand new things keep updating also have a look on this Best School in Faridabad
ReplyDeletesteroid satın al
ReplyDeleteheets
U3W