class Fib {
public static void main(String args[ ])
{
int n=Integer.parseInt(System.console().readLine("Enter the value of n="));
int i,a=0,b=1,c=0;
System.out.println("fibnoci series is:");
System.out.print(a);
System.out.print(" "+b);
for(i=0;i<n-2;i++)
{
c=a+b;
a=b;
b=c;
System.out.print(" "+c);
}
System.out.println();
System.out.print("th value of the series is: "+c);
}
}
No comments:
Post a Comment