0
print the series 0 1 1 2 3 5 8.....n terms
2 Respuestas
+ 1
Add scanner to define n.
0
public class Program
{
public static void main(String[] args) {
int fib1=0;
int fib2=1;
int fibonacci;
System.out.println(fib1);
System.out.println(fib2);
for (int i=1;i<n;i++)
{
fibonacci=fib1+fib2;
fib1=fib2;
fib2=fibonacci;
System.out.println(fibonacci);
}
}
}