Program to find fibonacci series in JAVA
class fib
{
public static void main(String[] arg)
{
int i,a=0,b=0,c=1;
int n=8;
System.out.println("fibonacci series"+n);
for(i=1;i<=n;i++)
{
a=b;
b=c;
c=a+b;
System.out.println(c);
}
}
}
class fib
{
public static void main(String[] arg)
{
int i,a=0,b=0,c=1;
int n=8;
System.out.println("fibonacci series"+n);
for(i=1;i<=n;i++)
{
a=b;
b=c;
c=a+b;
System.out.println(c);
}
}
}
No comments:
Post a Comment