class fibonacci
{
public static void main(String[] args)
{
int a = 20;
long[] b = new long[a];
b[0] = 0;
b[1] = 1;
//create the Fibonacci series and store it in an array
for(int i=2;i<a;i++)
{
b[i]=b[i-1]+b[i-2];
}
//print the Fibonacci series numbers
System.out.println("Fibonacci Series upto" + a);
for(int i=0;i<a;i++)
{
System.out.print(b[i] + ", ");
}
}
}
{
public static void main(String[] args)
{
int a = 20;
long[] b = new long[a];
b[0] = 0;
b[1] = 1;
//create the Fibonacci series and store it in an array
for(int i=2;i<a;i++)
{
b[i]=b[i-1]+b[i-2];
}
//print the Fibonacci series numbers
System.out.println("Fibonacci Series upto" + a);
for(int i=0;i<a;i++)
{
System.out.print(b[i] + ", ");
}
}
}
No comments:
Post a Comment