write a program to print the fibonacci series of the number given by the user in bluej.
Answers
Answered by
2
class Bluej
{
public static void main(int limit )
{
int a=0,b=1,c=0;
System.out.println("Fibonacci series ");
System.out.print(a+" "+b);
for(i=1;i<=limit;i++)
{
a=b;
b=c;
c=a+b;
System.out.print(c+" ");
}
}
}
For more java doubts follow me.
Mark me brainlest
Answered by
1
Answer:
import java.util.*;
class fibonacci
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("enter number of series: ");
int n=sc.nextInt();
int a =0,b=1,tv=0;
System.out.println("the series is"+a+""+b);
for(int i=3;i<=n;i++)
{
tv=a+b;
System.out.println("tv=" + tv);
a=b;
b=tv;
}
}
}
Explanation:
Similar questions