import java.io.*;
class simple_Fibonacci_sequence1
{
public static void main(String args[])
{
try
{
int a=0,b=1,i,sum,end,start;
DataInputStream cin=new DataInputStream(System.in);
System.out.println("Enter the starting value of series");
start=Integer.parseInt(cin.readLine());
System.out.println("Enter the end value of series");
end=Integer.parseInt(cin.readLine());
a=start;
System.out.println(a);
b=end;
System.out.println(b);
for(i=3;i<=end;i++)
{
sum=a+b;
System.out.println(sum);
a=b;
b=sum;
}
}
catch(Exception e)
{
System.out.println("wrong data ");
}
}
}
No comments:
Post a Comment