Thursday, 13 June 2013
program for Fibonacci series
import java.io.*;
class simple_Fibonacci
{
public static void main(String args[])
{
try
{
int a=0,b=1,i,sum;
DataInputStream cin=new DataInputStream(System.in);
System.out.println(a);
System.out.println(b);
for(i=3;i<=10;i++)
{
sum=a+b;
System.out.println(sum);
a=b;
b=sum;
}
}
catch(Exception e)
{
System.out.println("wrong data ");
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment