Java Source Code For Fibonacci Series
import java.io.*;
class Fibonaccis
{
public static void main(String args[])
{
int n=0,a=1,b=-1,sum=0;
System.out.print(" Enter The Limit For Fibonacci Series : ");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
try
{
n=Integer.parseInt(br.readLine());
}catch(Exception e){}
System.out.println(" The Fibonacci Series Is As Follows Below ");
while(n>0)
{
sum=a+b;
System.out.print(sum+" , ");
b=a;
a=sum;
n--;
}
}
}
Loading...
|
Comments :
Post a Comment