Write a java program to generate Fibonacci series.

import java.util.*;
class Fibonacci
{
int n;
Fibonacci()
{
Scanner s=new Scanner(System.in);
System.out.print("Enter the number of terms: ");
n=s.nextInt();
}
void show()
{
int f=0,s=1,t;
System.out.print(f+","+s);
for(int i=3;i<=n;i++)
{
t=f+s;
System.out.print(","+t);
f=s;
s=t;
}
}
}
class TestFibo
{
public static void main(String args[])
{
Fibonacci f= new Fibonacci();
f.show();
}

0 Comments