// simple_fibonnaci_sequence
import java.io.*;
class simple_Fibonacci_sequence
{
public static void main(String args[])
{
try
{
int no,i,a=1,b=1,c=0;
DataInputStream cin=new DataInputStream(System.in);
System.out.println("enter number for fibonnaci sequence");
no=Integer.parseInt(cin.readLine());
for(i=0;i<no-1;i++)
{
a=b+c;
System.out.println(""+a);
c=b;
b=a;
}
}
catch(Exception e)
{
System.out.println("wrong data");
}
}
}
No comments:
Post a Comment